|
|
@ -13,6 +13,7 @@ using System.Threading.Tasks; |
|
|
using ImageMagick; |
|
|
using ImageMagick; |
|
|
using PhotoSauce.MagicScaler; |
|
|
using PhotoSauce.MagicScaler; |
|
|
using SixLabors.ImageSharp.Formats.Jpeg; |
|
|
using SixLabors.ImageSharp.Formats.Jpeg; |
|
|
|
|
|
using SixLabors.ImageSharp.Memory; |
|
|
using SixLabors.ImageSharp.Processing; |
|
|
using SixLabors.ImageSharp.Processing; |
|
|
using SixLabors.ImageSharp.Tests; |
|
|
using SixLabors.ImageSharp.Tests; |
|
|
using SkiaSharp; |
|
|
using SkiaSharp; |
|
|
@ -53,6 +54,9 @@ namespace SixLabors.ImageSharp.Benchmarks.LoadResizeSave |
|
|
|
|
|
|
|
|
public int ThumbnailSize { get; set; } = 150; |
|
|
public int ThumbnailSize { get; set; } = 150; |
|
|
|
|
|
|
|
|
|
|
|
// Inject leaking memory allocation requests to ImageSharp processing code to stress-test finalizer behavior.
|
|
|
|
|
|
public bool EmulateLeakedAllocations { get; set; } |
|
|
|
|
|
|
|
|
private static readonly string[] ProgressiveFiles = |
|
|
private static readonly string[] ProgressiveFiles = |
|
|
{ |
|
|
{ |
|
|
"ancyloscelis-apiformis-m-paraguay-face_2014-08-08-095255-zs-pmax_15046500892_o.jpg", |
|
|
"ancyloscelis-apiformis-m-paraguay-face_2014-08-08-095255-zs-pmax_15046500892_o.jpg", |
|
|
@ -180,6 +184,12 @@ namespace SixLabors.ImageSharp.Benchmarks.LoadResizeSave |
|
|
using var image = ImageSharpImage.Load(input); |
|
|
using var image = ImageSharpImage.Load(input); |
|
|
this.IncreaseTotalMegapixels(image.Width, image.Height); |
|
|
this.IncreaseTotalMegapixels(image.Width, image.Height); |
|
|
|
|
|
|
|
|
|
|
|
if (this.EmulateLeakedAllocations) |
|
|
|
|
|
{ |
|
|
|
|
|
_ = Configuration.Default.MemoryAllocator.Allocate<long>(image.Width * image.Height); |
|
|
|
|
|
_ = Configuration.Default.MemoryAllocator.Allocate<byte>(1 << 21); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
image.Mutate(i => i.Resize(new ResizeOptions |
|
|
image.Mutate(i => i.Resize(new ResizeOptions |
|
|
{ |
|
|
{ |
|
|
Size = new ImageSharpSize(this.ThumbnailSize, this.ThumbnailSize), |
|
|
Size = new ImageSharpSize(this.ThumbnailSize, this.ThumbnailSize), |
|
|
@ -191,6 +201,11 @@ namespace SixLabors.ImageSharp.Benchmarks.LoadResizeSave |
|
|
|
|
|
|
|
|
// Save the results
|
|
|
// Save the results
|
|
|
image.Save(output, this.imageSharpJpegEncoder); |
|
|
image.Save(output, this.imageSharpJpegEncoder); |
|
|
|
|
|
|
|
|
|
|
|
if (this.EmulateLeakedAllocations) |
|
|
|
|
|
{ |
|
|
|
|
|
_ = Configuration.Default.MemoryAllocator.Allocate2D<long>(image.Width, image.Height); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
public void MagickResize(string input) |
|
|
public void MagickResize(string input) |
|
|
|