using BenchmarkDotNet.Attributes; using BenchmarkDotNet.Jobs; using HPPH.Reference; namespace HPPH.Benchmark; [SimpleJob(RuntimeMoniker.Net80)] [HtmlExporter] [MemoryDiagnoser] public class SortBenchmarks { #region Properties & Fields private readonly List _colors3bpp; private readonly List _colors4bpp; #endregion #region Constructors public SortBenchmarks() { _colors3bpp = BenchmarkHelper.GetSampleData(); _colors4bpp = BenchmarkHelper.GetSampleData(); } #endregion #region Methods [Benchmark] public void PixelHelper_3BPP() { foreach (ColorRGB[] colors in _colors3bpp) new Span(colors).SortByRed(); } [Benchmark] public void PixelHelper_4BPP() { foreach (ColorRGBA[] colors in _colors4bpp) new Span(colors).SortByRed(); } [Benchmark] public void Reference_3BPP() { foreach (ColorRGB[] colors in _colors3bpp) ReferencePixelHelper.SortByRed(new Span(colors)); } [Benchmark] public void Reference_4BPP() { foreach (ColorRGBA[] colors in _colors4bpp) ReferencePixelHelper.SortByRed(new Span(colors)); } #endregion }