mirror of https://github.com/SixLabors/ImageSharp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.4 KiB
51 lines
1.4 KiB
// <copyright file="DecodeGif.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 DecodeGif : BenchmarkBase
|
|
{
|
|
private byte[] gifBytes;
|
|
|
|
[Setup]
|
|
public void ReadImages()
|
|
{
|
|
if (this.gifBytes == null)
|
|
{
|
|
this.gifBytes = File.ReadAllBytes("../ImageSharp.Tests/TestImages/Formats/Gif/rings.gif");
|
|
}
|
|
}
|
|
|
|
[Benchmark(Baseline = true, Description = "System.Drawing Gif")]
|
|
public Size GifSystemDrawing()
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream(this.gifBytes))
|
|
{
|
|
using (Image image = Image.FromStream(memoryStream))
|
|
{
|
|
return image.Size;
|
|
}
|
|
}
|
|
}
|
|
|
|
[Benchmark(Description = "ImageSharp Gif")]
|
|
public CoreSize GifCore()
|
|
{
|
|
using (MemoryStream memoryStream = new MemoryStream(this.gifBytes))
|
|
{
|
|
CoreImage image = new CoreImage(memoryStream);
|
|
return new CoreSize(image.Width, image.Height);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|