31 lines
808 B
C#
31 lines
808 B
C#
using System.Numerics;
|
|
using BenchmarkDotNet.Attributes;
|
|
using BenchmarkDotNet.Jobs;
|
|
|
|
namespace SoulstormReplayReader.Benchmarks;
|
|
|
|
[SimpleJob(RuntimeMoniker.Net80)]
|
|
[MemoryDiagnoser]
|
|
public class TestBenchy
|
|
{
|
|
[Params(0xff3246aa, 0xff536ecd)]
|
|
public uint TestUInt;
|
|
|
|
[Benchmark]
|
|
public void ConvertBgraToArgbBits()
|
|
{
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
var u = (TestUInt & 0x000000FFU) << 24 | (TestUInt & 0x0000FF00U) << 8 | (TestUInt & 0x00FF0000U) >> 8 | (TestUInt & 0xFF000000U) >> 24;
|
|
}
|
|
}
|
|
|
|
[Benchmark]
|
|
public void ConvertBgraToArgbRotate()
|
|
{
|
|
for (int i = 0; i < 1000; i++)
|
|
{
|
|
var u = BitOperations.RotateRight(TestUInt & 0x00FF00FFu, 8) + BitOperations.RotateLeft(TestUInt & 0xFF00FF00u, 8);
|
|
}
|
|
}
|
|
} |