diff --git a/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs b/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs index 70ddb3000..5168d1d67 100644 --- a/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs +++ b/tests/ImageSharp.Tests/Formats/Jpg/JpegTests.cs @@ -13,13 +13,11 @@ namespace ImageSharp.Tests using ImageSharp.Formats.Jpg; - public class JpegTests + public class JpegTests : MeasureFixture { - private ITestOutputHelper Output { get; } - public JpegTests(ITestOutputHelper output) + : base(output) { - this.Output = output; } public static IEnumerable AllJpegFiles => TestImages.Jpeg.All; @@ -62,7 +60,7 @@ namespace ImageSharp.Tests private const int BenchmarkExecTimes = 30; - public static readonly string[] BenchmarkFiles = + public static readonly string[] EncoderBenchmarkFiles = { TestImages.Bmp.Car, TestImages.Bmp.NegHeight, TestImages.Bmp.F, TestImages.Png.Splash, @@ -72,11 +70,31 @@ namespace ImageSharp.Tests private const PixelTypes BenchmarkPixels = PixelTypes.StandardImageClass; //PixelTypes.Color | PixelTypes.Argb; + //[Theory] // Benchmark, enable manually + [InlineData(TestImages.Jpeg.Cmyk)] + [InlineData(TestImages.Jpeg.Ycck)] + [InlineData(TestImages.Jpeg.Calliphora)] + [InlineData(TestImages.Jpeg.Jpeg400)] + [InlineData(TestImages.Jpeg.Jpeg420)] + [InlineData(TestImages.Jpeg.Jpeg444)] + public void Benchmark_JpegDecoder(string fileName) + { + string path = TestFile.GetPath(fileName); + byte[] bytes = File.ReadAllBytes(path); + this.Measure( + 40, + () => + { + Image img = new Image(bytes); + }, + $"Decode {fileName}"); + + } //[Theory] // Benchmark, enable manually - [WithFileCollection(nameof(BenchmarkFiles), BenchmarkPixels, JpegSubsample.Ratio420, 75)] - [WithFileCollection(nameof(BenchmarkFiles), BenchmarkPixels, JpegSubsample.Ratio444, 75)] + [WithFileCollection(nameof(EncoderBenchmarkFiles), BenchmarkPixels, JpegSubsample.Ratio420, 75)] + [WithFileCollection(nameof(EncoderBenchmarkFiles), BenchmarkPixels, JpegSubsample.Ratio444, 75)] public void Benchmark_JpegEncoder(TestImageProvider provider, JpegSubsample subSample, int quality) where TColor : struct, IPackedPixel, IEquatable { diff --git a/tests/ImageSharp.Tests/TestFile.cs b/tests/ImageSharp.Tests/TestFile.cs index aab7c2620..892e344d6 100644 --- a/tests/ImageSharp.Tests/TestFile.cs +++ b/tests/ImageSharp.Tests/TestFile.cs @@ -34,12 +34,17 @@ namespace ImageSharp.Tests this.Bytes = File.ReadAllBytes(file); this.image = new Image(this.Bytes); } + + public static string GetPath(string file) + { + return Path.Combine(FormatsDirectory, file); + } public static TestFile Create(string file) { return cache.GetOrAdd(file, (string fileName) => { - return new TestFile(FormatsDirectory + fileName); + return new TestFile(GetPath(file)); }); } diff --git a/tests/ImageSharp.Tests/TestImages.cs b/tests/ImageSharp.Tests/TestImages.cs index e5b46b0e1..7265e45a4 100644 --- a/tests/ImageSharp.Tests/TestImages.cs +++ b/tests/ImageSharp.Tests/TestImages.cs @@ -56,7 +56,7 @@ namespace ImageSharp.Tests public const string Jpeg444 = "Jpg/baseline/jpeg444.jpg"; public static readonly string[] All = { - Cmyk, Exif, Floorplan, Calliphora, Turtle, Fb, Progress, GammaDalaiLamaGray, + Cmyk, Ycck, Exif, Floorplan, Calliphora, Turtle, Fb, Progress, GammaDalaiLamaGray, Festzug, Hiyamugi, Jpeg400, Jpeg420, Jpeg444, };