Browse Source

Add 'DecodeTiff' benchmark

pull/1570/head
Andrew Wilkinson 9 years ago
parent
commit
b2979f9b96
  1. 1
      tests/ImageSharp.Benchmarks/BenchmarkBase.cs
  2. 54
      tests/ImageSharp.Benchmarks/Image/DecodeTiff.cs

1
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());
}
}
}

54
tests/ImageSharp.Benchmarks/Image/DecodeTiff.cs

@ -0,0 +1,54 @@
// <copyright file="DecodeTiff.cs" company="James Jackson-South">
// Copyright (c) James Jackson-South and contributors.
// Licensed under the Apache License, Version 2.0.
// </copyright>
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<Rgba32> image = CoreImage.Load<Rgba32>(memoryStream))
{
return new CoreSize(image.Width, image.Height);
}
}
}
}
}
Loading…
Cancel
Save