Browse Source

tweak profiling benchmarks

pull/1574/head
Anton Firszov 6 years ago
parent
commit
fa5a435132
  1. 14
      tests/ImageSharp.Tests.ProfilingSandbox/Program.cs
  2. 31
      tests/ImageSharp.Tests/ProfilingBenchmarks/JpegProfilingBenchmarks.cs

14
tests/ImageSharp.Tests.ProfilingSandbox/Program.cs

@ -7,6 +7,10 @@ using SixLabors.ImageSharp.Tests.PixelFormats.PixelOperations;
using SixLabors.ImageSharp.Tests.ProfilingBenchmarks; using SixLabors.ImageSharp.Tests.ProfilingBenchmarks;
using Xunit.Abstractions; using Xunit.Abstractions;
// in this file, comments are used for disabling stuff for local execution
#pragma warning disable SA1515
#pragma warning disable SA1512
namespace SixLabors.ImageSharp.Tests.ProfilingSandbox namespace SixLabors.ImageSharp.Tests.ProfilingSandbox
{ {
public class Program public class Program
@ -28,10 +32,9 @@ namespace SixLabors.ImageSharp.Tests.ProfilingSandbox
public static void Main(string[] args) public static void Main(string[] args)
{ {
// RunJpegColorProfilingTests(); // RunJpegColorProfilingTests();
RunDecodeJpegProfilingTests();
// RunDecodeJpegProfilingTests();
// RunToVector4ProfilingTest(); // RunToVector4ProfilingTest();
RunResizeProfilingTest(); // RunResizeProfilingTest();
Console.ReadLine(); Console.ReadLine();
} }
@ -61,8 +64,11 @@ namespace SixLabors.ImageSharp.Tests.ProfilingSandbox
foreach (object[] data in JpegProfilingBenchmarks.DecodeJpegData) foreach (object[] data in JpegProfilingBenchmarks.DecodeJpegData)
{ {
string fileName = (string)data[0]; string fileName = (string)data[0];
benchmarks.DecodeJpeg(fileName); int executionCount = (int)data[1];
benchmarks.DecodeJpeg(fileName, executionCount);
} }
Console.WriteLine("DONE.");
} }
} }
} }

31
tests/ImageSharp.Tests/ProfilingBenchmarks/JpegProfilingBenchmarks.cs

@ -13,6 +13,9 @@ using SixLabors.ImageSharp.PixelFormats;
using Xunit; using Xunit;
using Xunit.Abstractions; using Xunit.Abstractions;
// in this file, comments are used for disabling stuff for local execution
#pragma warning disable SA1515
namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks
{ {
public class JpegProfilingBenchmarks : MeasureFixture public class JpegProfilingBenchmarks : MeasureFixture
@ -22,24 +25,28 @@ namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks
{ {
} }
public static readonly TheoryData<string> DecodeJpegData = new TheoryData<string> public static readonly TheoryData<string, int> DecodeJpegData = new TheoryData<string, int>
{ {
TestImages.Jpeg.BenchmarkSuite.Jpeg400_SmallMonochrome, { TestImages.Jpeg.BenchmarkSuite.Jpeg400_SmallMonochrome, 20 },
TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr, { TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr, 20 },
TestImages.Jpeg.BenchmarkSuite.Lake_Small444YCbCr, { TestImages.Jpeg.BenchmarkSuite.Lake_Small444YCbCr, 40 },
TestImages.Jpeg.BenchmarkSuite.MissingFF00ProgressiveBedroom159_MidSize420YCbCr, // TestImages.Jpeg.BenchmarkSuite.MissingFF00ProgressiveBedroom159_MidSize420YCbCr,
TestImages.Jpeg.BenchmarkSuite.BadRstProgressive518_Large444YCbCr, // TestImages.Jpeg.BenchmarkSuite.BadRstProgressive518_Large444YCbCr,
TestImages.Jpeg.BenchmarkSuite.ExifGetString750Transform_Huge420YCbCr, { TestImages.Jpeg.BenchmarkSuite.ExifGetString750Transform_Huge420YCbCr, 5 }
}; };
[Theory(Skip = ProfilingSetup.SkipProfilingTests)] [Theory(Skip = ProfilingSetup.SkipProfilingTests)]
[MemberData(nameof(DecodeJpegData))] [MemberData(nameof(DecodeJpegData))]
public void DecodeJpeg(string fileName) public void DecodeJpeg(string fileName, int executionCount)
{ {
this.DecodeJpegBenchmarkImpl(fileName, new JpegDecoder()); var decoder = new JpegDecoder()
{
IgnoreMetadata = true
};
this.DecodeJpegBenchmarkImpl(fileName, decoder, executionCount);
} }
private void DecodeJpegBenchmarkImpl(string fileName, IImageDecoder decoder) private void DecodeJpegBenchmarkImpl(string fileName, IImageDecoder decoder, int executionCount)
{ {
// do not run this on CI even by accident // do not run this on CI even by accident
if (TestEnvironment.RunsOnCI) if (TestEnvironment.RunsOnCI)
@ -47,8 +54,6 @@ namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks
return; return;
} }
const int ExecutionCount = 20;
if (!Vector.IsHardwareAccelerated) if (!Vector.IsHardwareAccelerated)
{ {
throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)"); throw new Exception("Vector.IsHardwareAccelerated == false! ('prefer32 bit' enabled?)");
@ -58,7 +63,7 @@ namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks
byte[] bytes = File.ReadAllBytes(path); byte[] bytes = File.ReadAllBytes(path);
this.Measure( this.Measure(
ExecutionCount, executionCount,
() => () =>
{ {
var img = Image.Load<Rgba32>(bytes, decoder); var img = Image.Load<Rgba32>(bytes, decoder);

Loading…
Cancel
Save