diff --git a/tests/ImageSharp.Benchmarks/BenchmarkBase.cs b/tests/ImageSharp.Benchmarks/BenchmarkBase.cs index d6e8ac692..b1aadac0a 100644 --- a/tests/ImageSharp.Benchmarks/BenchmarkBase.cs +++ b/tests/ImageSharp.Benchmarks/BenchmarkBase.cs @@ -17,6 +17,7 @@ Configuration.Default.AddImageFormat(new PngFormat()); Configuration.Default.AddImageFormat(new BmpFormat()); Configuration.Default.AddImageFormat(new GifFormat()); + Configuration.Default.AddImageFormat(new TiffFormat()); } } } diff --git a/tests/ImageSharp.Benchmarks/Image/DecodeTiff.cs b/tests/ImageSharp.Benchmarks/Image/DecodeTiff.cs new file mode 100644 index 000000000..3c57e5fd2 --- /dev/null +++ b/tests/ImageSharp.Benchmarks/Image/DecodeTiff.cs @@ -0,0 +1,54 @@ +// +// Copyright (c) James Jackson-South and contributors. +// Licensed under the Apache License, Version 2.0. +// + +namespace ImageSharp.Benchmarks.Image +{ + using System.Drawing; + using System.IO; + + using BenchmarkDotNet.Attributes; + + using CoreImage = ImageSharp.Image; + + using CoreSize = ImageSharp.Size; + + public class DecodeTiff : BenchmarkBase + { + private byte[] tiffBytes; + + [GlobalSetup] + public void ReadImages() + { + if (this.tiffBytes == null) + { + this.tiffBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Tiff/Calliphora_rgb_uncompressed.tiff"); + } + } + + [Benchmark(Baseline = true, Description = "System.Drawing Tiff")] + public Size TiffSystemDrawing() + { + using (MemoryStream memoryStream = new MemoryStream(this.tiffBytes)) + { + using (Image image = Image.FromStream(memoryStream)) + { + return image.Size; + } + } + } + + [Benchmark(Description = "ImageSharp Tiff")] + public CoreSize TiffCore() + { + using (MemoryStream memoryStream = new MemoryStream(this.tiffBytes)) + { + using (Image image = CoreImage.Load(memoryStream)) + { + return new CoreSize(image.Width, image.Height); + } + } + } + } +}