|
|
|
@ -16,17 +16,20 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg |
|
|
|
private Stream bmpStream; |
|
|
|
private SDImage bmpDrawing; |
|
|
|
private Image<Rgba32> bmpCore; |
|
|
|
private MemoryStream destinationStream; |
|
|
|
|
|
|
|
[GlobalSetup] |
|
|
|
public void ReadImages() |
|
|
|
{ |
|
|
|
if (this.bmpStream == null) |
|
|
|
{ |
|
|
|
const string TestImage = TestImages.Bmp.NegHeight; |
|
|
|
const string TestImage = TestImages.Jpeg.BenchmarkSuite.Jpeg420Exif_MidSizeYCbCr; |
|
|
|
this.bmpStream = File.OpenRead(Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, TestImage)); |
|
|
|
this.bmpCore = Image.Load<Rgba32>(this.bmpStream); |
|
|
|
this.bmpCore.Metadata.ExifProfile = null; |
|
|
|
this.bmpStream.Position = 0; |
|
|
|
this.bmpDrawing = SDImage.FromStream(this.bmpStream); |
|
|
|
this.destinationStream = new MemoryStream(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -42,15 +45,15 @@ namespace SixLabors.ImageSharp.Benchmarks.Codecs.Jpeg |
|
|
|
[Benchmark(Baseline = true, Description = "System.Drawing Jpeg")] |
|
|
|
public void JpegSystemDrawing() |
|
|
|
{ |
|
|
|
using var stream = new MemoryStream(); |
|
|
|
this.bmpDrawing.Save(stream, ImageFormat.Jpeg); |
|
|
|
this.bmpDrawing.Save(this.destinationStream, ImageFormat.Jpeg); |
|
|
|
this.destinationStream.Seek(0, SeekOrigin.Begin); |
|
|
|
} |
|
|
|
|
|
|
|
[Benchmark(Description = "ImageSharp Jpeg")] |
|
|
|
public void JpegCore() |
|
|
|
{ |
|
|
|
using var stream = new MemoryStream(); |
|
|
|
this.bmpCore.SaveAsJpeg(stream); |
|
|
|
this.bmpCore.SaveAsJpeg(this.destinationStream); |
|
|
|
this.destinationStream.Seek(0, SeekOrigin.Begin); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|