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.
38 lines
1.1 KiB
38 lines
1.1 KiB
// Copyright (c) Six Labors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
|
|
using System.IO;
|
|
using BenchmarkDotNet.Attributes;
|
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
|
using SixLabors.ImageSharp.Tests;
|
|
|
|
namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg
|
|
{
|
|
[Config(typeof(Config.ShortMultiFramework))]
|
|
public class IdentifyJpeg
|
|
{
|
|
private byte[] jpegBytes;
|
|
|
|
private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage);
|
|
|
|
[Params(TestImages.Jpeg.Baseline.Jpeg420Exif, TestImages.Jpeg.Baseline.Calliphora)]
|
|
public string TestImage { get; set; }
|
|
|
|
[GlobalSetup]
|
|
public void ReadImages()
|
|
{
|
|
if (this.jpegBytes == null)
|
|
{
|
|
this.jpegBytes = File.ReadAllBytes(this.TestImageFullPath);
|
|
}
|
|
}
|
|
|
|
[Benchmark]
|
|
public IImageInfo Identify()
|
|
{
|
|
using var memoryStream = new MemoryStream(this.jpegBytes);
|
|
var decoder = new JpegDecoder();
|
|
return decoder.Identify(Configuration.Default, memoryStream);
|
|
}
|
|
}
|
|
}
|
|
|