diff --git a/AssetRipper.TextureDecoder.Benchmarks/Argb32Decoding.cs b/AssetRipper.TextureDecoder.Benchmarks/Argb32Decoding.cs new file mode 100644 index 0000000..08c0328 --- /dev/null +++ b/AssetRipper.TextureDecoder.Benchmarks/Argb32Decoding.cs @@ -0,0 +1,27 @@ +using AssetRipper.TextureDecoder.Rgb; +using AssetRipper.TextureDecoder.Rgb.Formats; +using BenchmarkDotNet.Attributes; + +namespace AssetRipper.TextureDecoder.Benchmarks; + +public class Argb32Decoding +{ + private const string PathToRepositoryRoot = "../../../../../../../../"; + private const string PathToTestFiles = PathToRepositoryRoot + "TestFiles/"; + private const int Width = 256;//ignoring smaller mips + private const int Height = 256;//ignoring smaller mips + private readonly byte[] inputData; + private readonly byte[] outputData; + + public Argb32Decoding() + { + inputData = File.ReadAllBytes(PathToTestFiles + "Rgb/" + "test.argb32"); + outputData = new byte[Width * Height * sizeof(uint)]; + } + + [Benchmark] + public int OriginalMethod() => RgbConverter.ARGB32ToBGRA32(inputData, Width, Height, outputData); + + [Benchmark] + public int GenericMethod() => RgbConverter.Convert(inputData, Width, Height, outputData); +} \ No newline at end of file diff --git a/AssetRipper.TextureDecoder.Benchmarks/AssetRipper.TextureDecoder.Benchmarks.csproj b/AssetRipper.TextureDecoder.Benchmarks/AssetRipper.TextureDecoder.Benchmarks.csproj new file mode 100644 index 0000000..70495f6 --- /dev/null +++ b/AssetRipper.TextureDecoder.Benchmarks/AssetRipper.TextureDecoder.Benchmarks.csproj @@ -0,0 +1,18 @@ + + + + Exe + net6.0 + enable + enable + + + + + + + + + + + diff --git a/AssetRipper.TextureDecoder.Benchmarks/Program.cs b/AssetRipper.TextureDecoder.Benchmarks/Program.cs new file mode 100644 index 0000000..9e12740 --- /dev/null +++ b/AssetRipper.TextureDecoder.Benchmarks/Program.cs @@ -0,0 +1,11 @@ +using BenchmarkDotNet.Running; + +namespace AssetRipper.TextureDecoder.Benchmarks; + +internal class Program +{ + static void Main() + { + BenchmarkRunner.Run(typeof(Program).Assembly); + } +} \ No newline at end of file diff --git a/TextureDecoder.sln b/TextureDecoder.sln index caa557b..4dbdead 100644 --- a/TextureDecoder.sln +++ b/TextureDecoder.sln @@ -28,6 +28,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder. EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AssetRipper.TextureDecoder.ConsoleApp", "AssetRipper.TextureDecoder.ConsoleApp\AssetRipper.TextureDecoder.ConsoleApp.csproj", "{FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AssetRipper.TextureDecoder.Benchmarks", "AssetRipper.TextureDecoder.Benchmarks\AssetRipper.TextureDecoder.Benchmarks.csproj", "{F85804F4-4864-412E-BDC6-8B6E2B5646A7}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -50,6 +52,10 @@ Global {FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Debug|Any CPU.Build.0 = Debug|Any CPU {FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Release|Any CPU.ActiveCfg = Release|Any CPU {FFC8EEF8-8BF1-4B65-ADDA-A949EDDF4CB4}.Release|Any CPU.Build.0 = Release|Any CPU + {F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F85804F4-4864-412E-BDC6-8B6E2B5646A7}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE