-
-
Notifications
You must be signed in to change notification settings - Fork 852
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update missed test and benchmarks project
- Loading branch information
1 parent
d14c820
commit 5528a29
Showing
125 changed files
with
8,147 additions
and
8,364 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,47 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.IO; | ||
using BenchmarkDotNet.Attributes; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using SixLabors.ImageSharp.Tests; | ||
using SDImage = System.Drawing.Image; | ||
using SDSize = System.Drawing.Size; | ||
|
||
namespace SixLabors.ImageSharp.Benchmarks.Codecs | ||
namespace SixLabors.ImageSharp.Benchmarks.Codecs; | ||
|
||
[Config(typeof(Config.ShortMultiFramework))] | ||
public class DecodeBmp | ||
{ | ||
[Config(typeof(Config.ShortMultiFramework))] | ||
public class DecodeBmp | ||
{ | ||
private byte[] bmpBytes; | ||
private byte[] bmpBytes; | ||
|
||
private string TestImageFullPath | ||
=> Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); | ||
private string TestImageFullPath | ||
=> Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); | ||
|
||
[GlobalSetup] | ||
public void ReadImages() | ||
[GlobalSetup] | ||
public void ReadImages() | ||
{ | ||
if (this.bmpBytes == null) | ||
{ | ||
if (this.bmpBytes == null) | ||
{ | ||
this.bmpBytes = File.ReadAllBytes(this.TestImageFullPath); | ||
} | ||
this.bmpBytes = File.ReadAllBytes(this.TestImageFullPath); | ||
} | ||
} | ||
|
||
[Params(TestImages.Bmp.Car)] | ||
public string TestImage { get; set; } | ||
[Params(TestImages.Bmp.Car)] | ||
public string TestImage { get; set; } | ||
|
||
[Benchmark(Baseline = true, Description = "System.Drawing Bmp")] | ||
public SDSize BmpSystemDrawing() | ||
{ | ||
using var memoryStream = new MemoryStream(this.bmpBytes); | ||
using var image = SDImage.FromStream(memoryStream); | ||
return image.Size; | ||
} | ||
[Benchmark(Baseline = true, Description = "System.Drawing Bmp")] | ||
public SDSize BmpSystemDrawing() | ||
{ | ||
using var memoryStream = new MemoryStream(this.bmpBytes); | ||
using var image = SDImage.FromStream(memoryStream); | ||
return image.Size; | ||
} | ||
|
||
[Benchmark(Description = "ImageSharp Bmp")] | ||
public Size BmpImageSharp() | ||
{ | ||
using var memoryStream = new MemoryStream(this.bmpBytes); | ||
using var image = Image.Load<Rgba32>(memoryStream); | ||
return new Size(image.Width, image.Height); | ||
} | ||
[Benchmark(Description = "ImageSharp Bmp")] | ||
public Size BmpImageSharp() | ||
{ | ||
using var memoryStream = new MemoryStream(this.bmpBytes); | ||
using var image = Image.Load<Rgba32>(memoryStream); | ||
return new Size(image.Width, image.Height); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 19 additions & 21 deletions
40
tests/ImageSharp.Benchmarks/Codecs/Bmp/EncodeBmpMultiple.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,30 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.Collections.Generic; | ||
using System.Drawing.Imaging; | ||
using BenchmarkDotNet.Attributes; | ||
using SixLabors.ImageSharp.Formats.Bmp; | ||
|
||
namespace SixLabors.ImageSharp.Benchmarks.Codecs | ||
namespace SixLabors.ImageSharp.Benchmarks.Codecs; | ||
|
||
[Config(typeof(Config.ShortMultiFramework))] | ||
public class EncodeBmpMultiple : MultiImageBenchmarkBase.WithImagesPreloaded | ||
{ | ||
[Config(typeof(Config.ShortMultiFramework))] | ||
public class EncodeBmpMultiple : MultiImageBenchmarkBase.WithImagesPreloaded | ||
{ | ||
protected override IEnumerable<string> InputImageSubfoldersOrFiles => new[] { "Bmp/", "Jpg/baseline" }; | ||
protected override IEnumerable<string> InputImageSubfoldersOrFiles => new[] { "Bmp/", "Jpg/baseline" }; | ||
|
||
[Benchmark(Description = "EncodeBmpMultiple - ImageSharp")] | ||
public void EncodeBmpImageSharp() | ||
=> this.ForEachImageSharpImage((img, ms) => | ||
{ | ||
img.Save(ms, new BmpEncoder()); | ||
return null; | ||
}); | ||
[Benchmark(Description = "EncodeBmpMultiple - ImageSharp")] | ||
public void EncodeBmpImageSharp() | ||
=> this.ForEachImageSharpImage((img, ms) => | ||
{ | ||
img.Save(ms, new BmpEncoder()); | ||
return null; | ||
}); | ||
|
||
[Benchmark(Baseline = true, Description = "EncodeBmpMultiple - System.Drawing")] | ||
public void EncodeBmpSystemDrawing() | ||
=> this.ForEachSystemDrawingImage((img, ms) => | ||
{ | ||
img.Save(ms, ImageFormat.Bmp); | ||
return null; | ||
}); | ||
} | ||
[Benchmark(Baseline = true, Description = "EncodeBmpMultiple - System.Drawing")] | ||
public void EncodeBmpSystemDrawing() | ||
=> this.ForEachSystemDrawingImage((img, ms) => | ||
{ | ||
img.Save(ms, ImageFormat.Bmp); | ||
return null; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,49 +1,47 @@ | ||
// Copyright (c) Six Labors. | ||
// Licensed under the Six Labors Split License. | ||
|
||
using System.IO; | ||
using BenchmarkDotNet.Attributes; | ||
using SixLabors.ImageSharp.PixelFormats; | ||
using SixLabors.ImageSharp.Tests; | ||
using SDImage = System.Drawing.Image; | ||
using SDSize = System.Drawing.Size; | ||
|
||
namespace SixLabors.ImageSharp.Benchmarks.Codecs | ||
namespace SixLabors.ImageSharp.Benchmarks.Codecs; | ||
|
||
[Config(typeof(Config.ShortMultiFramework))] | ||
public class DecodeGif | ||
{ | ||
[Config(typeof(Config.ShortMultiFramework))] | ||
public class DecodeGif | ||
{ | ||
private byte[] gifBytes; | ||
private byte[] gifBytes; | ||
|
||
private string TestImageFullPath | ||
=> Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); | ||
private string TestImageFullPath | ||
=> Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); | ||
|
||
[GlobalSetup] | ||
public void ReadImages() | ||
[GlobalSetup] | ||
public void ReadImages() | ||
{ | ||
if (this.gifBytes == null) | ||
{ | ||
if (this.gifBytes == null) | ||
{ | ||
this.gifBytes = File.ReadAllBytes(this.TestImageFullPath); | ||
} | ||
this.gifBytes = File.ReadAllBytes(this.TestImageFullPath); | ||
} | ||
} | ||
|
||
[Params(TestImages.Gif.Rings)] | ||
public string TestImage { get; set; } | ||
[Params(TestImages.Gif.Rings)] | ||
public string TestImage { get; set; } | ||
|
||
[Benchmark(Baseline = true, Description = "System.Drawing Gif")] | ||
public SDSize GifSystemDrawing() | ||
{ | ||
using var memoryStream = new MemoryStream(this.gifBytes); | ||
using var image = SDImage.FromStream(memoryStream); | ||
return image.Size; | ||
} | ||
[Benchmark(Baseline = true, Description = "System.Drawing Gif")] | ||
public SDSize GifSystemDrawing() | ||
{ | ||
using var memoryStream = new MemoryStream(this.gifBytes); | ||
using var image = SDImage.FromStream(memoryStream); | ||
return image.Size; | ||
} | ||
|
||
[Benchmark(Description = "ImageSharp Gif")] | ||
public Size GifImageSharp() | ||
{ | ||
using var memoryStream = new MemoryStream(this.gifBytes); | ||
using var image = Image.Load<Rgba32>(memoryStream); | ||
return new Size(image.Width, image.Height); | ||
} | ||
[Benchmark(Description = "ImageSharp Gif")] | ||
public Size GifImageSharp() | ||
{ | ||
using var memoryStream = new MemoryStream(this.gifBytes); | ||
using var image = Image.Load<Rgba32>(memoryStream); | ||
return new Size(image.Width, image.Height); | ||
} | ||
} |
Oops, something went wrong.