From 387bdfa53341eb7afecc1864001852b71c74daf8 Mon Sep 17 00:00:00 2001 From: Anton Firszov Date: Sun, 3 Oct 2021 04:19:14 +0200 Subject: [PATCH] fix ProfilingSandbox --- .../Formats/Jpg/JpegColorConverterTests.cs | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs index f2bc8a733..1504684ae 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegColorConverterTests.cs @@ -341,6 +341,32 @@ namespace SixLabors.ImageSharp.Tests.Formats.Jpg seed); } + // Benchmark, for local execution only + // [Theory] + // [InlineData(false)] + // [InlineData(true)] + public void BenchmarkYCbCr(bool simd) + { + int count = 2053; + int times = 50000; + + JpegColorConverter.ComponentValues values = CreateRandomValues(3, count, 1); + var result = new Vector4[count]; + + JpegColorConverter converter = simd ? (JpegColorConverter)new JpegColorConverter.FromYCbCrVector4(8) : new JpegColorConverter.FromYCbCrBasic(8); + + // Warm up: + converter.ConvertToRgbInplace(values); + + using (new MeasureGuard(this.Output, $"{converter.GetType().Name} x {times}")) + { + for (int i = 0; i < times; i++) + { + converter.ConvertToRgbInplace(values); + } + } + } + private static JpegColorConverter.ComponentValues CreateRandomValues( int componentCount, int inputBufferLength,