📷 A modern, cross-platform, 2D Graphics library for .NET
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.
 
 

45 lines
1.3 KiB

// Copyright (c) Six Labors.
// Licensed under the Six Labors Split License.
using SixLabors.ImageSharp.Formats;
using SixLabors.ImageSharp.Processing;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests.ProfilingBenchmarks;
public class LoadResizeSaveProfilingBenchmarks : MeasureFixture
{
public LoadResizeSaveProfilingBenchmarks(ITestOutputHelper output)
: base(output)
{
}
[Theory(Skip = ProfilingSetup.SkipProfilingTests)]
[InlineData(TestImages.Jpeg.Baseline.Jpeg420Exif)]
public void LoadResizeSave(string imagePath)
{
var configuration = Configuration.CreateDefaultInstance();
configuration.MaxDegreeOfParallelism = 1;
DecoderOptions options = new()
{
Configuration = configuration
};
byte[] imageBytes = TestFile.Create(imagePath).Bytes;
using var ms = new MemoryStream();
this.Measure(
30,
() =>
{
using (var image = Image.Load(options, imageBytes))
{
image.Mutate(x => x.Resize(image.Size / 4));
image.SaveAsJpeg(ms);
}
ms.Seek(0, SeekOrigin.Begin);
});
}
}