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.
44 lines
1.5 KiB
44 lines
1.5 KiB
// <copyright file="EncodeJpegMultiple.cs" company="James Jackson-South">
|
|
// Copyright (c) James Jackson-South and contributors.
|
|
// Licensed under the Apache License, Version 2.0.
|
|
// </copyright>
|
|
|
|
namespace SixLabors.ImageSharp.Benchmarks.Image.Jpeg
|
|
{
|
|
using System.Collections.Generic;
|
|
using System.Drawing.Imaging;
|
|
|
|
using BenchmarkDotNet.Attributes;
|
|
|
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
|
|
|
[Config(typeof(Config.ShortClr))] // It's long enough to iterate through multiple files
|
|
public class EncodeJpegMultiple : MultiImageBenchmarkBase.WithImagesPreloaded
|
|
{
|
|
protected override IEnumerable<string> InputImageSubfoldersOrFiles => new[] { "Bmp/", "Jpg/baseline" };
|
|
|
|
protected override IEnumerable<string> SearchPatterns => new[] { "*.bmp", "*.jpg" };
|
|
|
|
[Benchmark(Description = "EncodeJpegMultiple - ImageSharp")]
|
|
public void EncodeJpegImageSharp()
|
|
{
|
|
this.ForEachImageSharpImage(
|
|
(img, ms) =>
|
|
{
|
|
img.Save(ms, new JpegEncoder());
|
|
return null;
|
|
});
|
|
}
|
|
|
|
[Benchmark(Baseline = true, Description = "EncodeJpegMultiple - System.Drawing")]
|
|
public void EncodeJpegSystemDrawing()
|
|
{
|
|
this.ForEachSystemDrawingImage(
|
|
(img, ms) =>
|
|
{
|
|
img.Save(ms, ImageFormat.Jpeg);
|
|
return null;
|
|
});
|
|
}
|
|
}
|
|
}
|