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.
52 lines
1.4 KiB
52 lines
1.4 KiB
using System.IO;
|
|
|
|
using SixLabors.ImageSharp.Formats.Jpeg;
|
|
using SixLabors.ImageSharp.PixelFormats;
|
|
using SixLabors.ImageSharp.Processing;
|
|
using SixLabors.Primitives;
|
|
|
|
using Xunit;
|
|
using Xunit.Abstractions;
|
|
|
|
namespace SixLabors.ImageSharp.Tests
|
|
{
|
|
public class ProfilingBenchmarks : MeasureFixture
|
|
{
|
|
public const string SkipProfilingTests =
|
|
#if true
|
|
null;
|
|
#else
|
|
"Profiling benchmark, enable manually!";
|
|
#endif
|
|
|
|
|
|
public ProfilingBenchmarks(ITestOutputHelper output)
|
|
: base(output)
|
|
{
|
|
}
|
|
|
|
[Theory(Skip = SkipProfilingTests)]
|
|
[InlineData(TestImages.Jpeg.Baseline.Jpeg420Exif)]
|
|
public void LoadResizeSave(string imagePath)
|
|
{
|
|
var configuration = Configuration.CreateDefaultInstance();
|
|
configuration.MaxDegreeOfParallelism = 1;
|
|
|
|
byte[] imageBytes = TestFile.Create(imagePath).Bytes;
|
|
|
|
using (var ms = new MemoryStream())
|
|
{
|
|
this.Measure(30,
|
|
() =>
|
|
{
|
|
using (var image = Image.Load(configuration, imageBytes))
|
|
{
|
|
image.Mutate(x => x.Resize(image.Size() / 4));
|
|
image.SaveAsJpeg(ms);
|
|
}
|
|
ms.Seek(0, SeekOrigin.Begin);
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|