mirror of https://github.com/SixLabors/ImageSharp
5 changed files with 106 additions and 11 deletions
@ -0,0 +1,42 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System.IO; |
||||
|
|
||||
|
using BenchmarkDotNet.Attributes; |
||||
|
|
||||
|
using ImageMagick; |
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Tests; |
||||
|
using SixLabors.Primitives; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Benchmarks.Codecs |
||||
|
{ |
||||
|
[Config(typeof(Config.ShortClr))] |
||||
|
public class DecodeTga : BenchmarkBase |
||||
|
{ |
||||
|
private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); |
||||
|
|
||||
|
[Params(TestImages.Tga.Bit24)] |
||||
|
public string TestImage { get; set; } |
||||
|
|
||||
|
[Benchmark(Baseline = true, Description = "ImageMagick Tga")] |
||||
|
public Size TgaImageMagick() |
||||
|
{ |
||||
|
using (var magickImage = new MagickImage(this.TestImageFullPath)) |
||||
|
{ |
||||
|
return new Size(magickImage.Width, magickImage.Height); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Benchmark(Description = "ImageSharp Tga")] |
||||
|
public Size TgaCore() |
||||
|
{ |
||||
|
using (var image = Image.Load<Rgba32>(this.TestImageFullPath)) |
||||
|
{ |
||||
|
return new Size(image.Width, image.Height); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,54 @@ |
|||||
|
// Copyright (c) Six Labors and contributors.
|
||||
|
// Licensed under the Apache License, Version 2.0.
|
||||
|
|
||||
|
using System.IO; |
||||
|
|
||||
|
using BenchmarkDotNet.Attributes; |
||||
|
|
||||
|
using ImageMagick; |
||||
|
|
||||
|
using SixLabors.ImageSharp.PixelFormats; |
||||
|
using SixLabors.ImageSharp.Tests; |
||||
|
|
||||
|
namespace SixLabors.ImageSharp.Benchmarks.Codecs |
||||
|
{ |
||||
|
[Config(typeof(Config.ShortClr))] |
||||
|
public class EncodeTga : BenchmarkBase |
||||
|
{ |
||||
|
private MagickImage tgaMagick; |
||||
|
private Image<Rgba32> tgaCore; |
||||
|
|
||||
|
private string TestImageFullPath => Path.Combine(TestEnvironment.InputImagesDirectoryFullPath, this.TestImage); |
||||
|
|
||||
|
[Params(TestImages.Tga.Bit24)] |
||||
|
public string TestImage { get; set; } |
||||
|
|
||||
|
[GlobalSetup] |
||||
|
public void ReadImages() |
||||
|
{ |
||||
|
if (this.tgaCore == null) |
||||
|
{ |
||||
|
this.tgaCore = Image.Load<Rgba32>(TestImageFullPath); |
||||
|
this.tgaMagick = new MagickImage(this.TestImageFullPath); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Benchmark(Baseline = true, Description = "Magick Tga")] |
||||
|
public void BmpSystemDrawing() |
||||
|
{ |
||||
|
using (var memoryStream = new MemoryStream()) |
||||
|
{ |
||||
|
this.tgaMagick.Write(memoryStream, MagickFormat.Tga); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Benchmark(Description = "ImageSharp Tga")] |
||||
|
public void BmpCore() |
||||
|
{ |
||||
|
using (var memoryStream = new MemoryStream()) |
||||
|
{ |
||||
|
this.tgaCore.SaveAsBmp(memoryStream); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue