forked from SixLabors/ImageSharp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
SixLabors#12 Add benchmarks for big tiff files
- Loading branch information
1 parent
72e1afd
commit 96d9158
Showing
5 changed files
with
132 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,108 @@ | ||
//Copyright(c) Six Labors and contributors. | ||
//Licensed under the Apache License, Version 2.0. | ||
|
||
using System.IO; | ||
|
||
using BenchmarkDotNet.Attributes; | ||
|
||
using SixLabors.ImageSharp.PixelFormats; | ||
|
||
using CoreImage = SixLabors.ImageSharp.Image; | ||
using CoreSize = SixLabors.Primitives.Size; | ||
|
||
namespace SixLabors.ImageSharp.Benchmarks.Codecs | ||
{ | ||
[Config(typeof(Config.LongClr))] | ||
public class DecodeTiffBig : BenchmarkBase | ||
{ | ||
private byte[] grayscale_uncompressed; | ||
|
||
private byte[] palette_uncompressed; | ||
|
||
private byte[] rgb_deflate; | ||
|
||
////private byte[] rgb_jpeg; | ||
|
||
private byte[] rgb_lzw; | ||
|
||
private byte[] rgb_packbits; | ||
|
||
private byte[] rgb_uncompressed; | ||
|
||
[GlobalSetup] | ||
public void ReadImages() | ||
{ | ||
if (this.grayscale_uncompressed == null) | ||
{ | ||
string path = @"C:\Work\GitHub\SixLabors.ImageSharp\tests\ImageSharp.Tests\TestImages\Formats\Tiff\"; | ||
this.grayscale_uncompressed = File.ReadAllBytes(path + "jpeg444_big_grayscale_uncompressed.tiff"); | ||
this.palette_uncompressed = File.ReadAllBytes(path + "jpeg444_big_palette_uncompressed.tiff"); | ||
this.rgb_deflate = File.ReadAllBytes(path + "jpeg444_big_rgb_deflate.tiff"); | ||
////this.rgb_jpeg = File.ReadAllBytes(path + "jpeg444_big_rgb_jpeg.tiff"); | ||
this.rgb_lzw = File.ReadAllBytes(path + "jpeg444_big_rgb_lzw.tiff"); | ||
this.rgb_packbits = File.ReadAllBytes(path + "jpeg444_big_rgb_packbits.tiff"); | ||
this.rgb_uncompressed = File.ReadAllBytes(path + "jpeg444_big_rgb_uncompressed.tiff"); | ||
} | ||
} | ||
|
||
[Benchmark(Description = "Tiff grayscale_uncompressed")] | ||
public CoreSize GrayscaleUncompressed() | ||
{ | ||
using (MemoryStream ms = new MemoryStream(this.grayscale_uncompressed)) | ||
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(ms)) | ||
{ | ||
return new CoreSize(image.Width, image.Height); | ||
} | ||
} | ||
|
||
[Benchmark(Description = "Tiff palette_uncompressed")] | ||
public CoreSize PaletteUncompressed() | ||
{ | ||
using (MemoryStream ms = new MemoryStream(this.palette_uncompressed)) | ||
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(ms)) | ||
{ | ||
return new CoreSize(image.Width, image.Height); | ||
} | ||
} | ||
|
||
[Benchmark(Description = "Tiff rgb_deflate")] | ||
public CoreSize RgbDeflate() | ||
{ | ||
using (MemoryStream ms = new MemoryStream(this.rgb_deflate)) | ||
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(ms)) | ||
{ | ||
return new CoreSize(image.Width, image.Height); | ||
} | ||
} | ||
|
||
[Benchmark(Description = "Tiff rgb_lzw")] | ||
public CoreSize RgbLzw() | ||
{ | ||
using (MemoryStream ms = new MemoryStream(this.rgb_lzw)) | ||
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(ms)) | ||
{ | ||
return new CoreSize(image.Width, image.Height); | ||
} | ||
} | ||
|
||
[Benchmark(Description = "Tiff rgb_packbits")] | ||
public CoreSize RgbPackbits() | ||
{ | ||
using (MemoryStream ms = new MemoryStream(this.rgb_packbits)) | ||
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(ms)) | ||
{ | ||
return new CoreSize(image.Width, image.Height); | ||
} | ||
} | ||
|
||
[Benchmark(Description = "Tiff rgb_uncompressed")] | ||
public CoreSize RgbUncompressed() | ||
{ | ||
using (MemoryStream ms = new MemoryStream(this.rgb_uncompressed)) | ||
using (Image<Rgba32> image = CoreImage.Load<Rgba32>(ms)) | ||
{ | ||
return new CoreSize(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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
powershell -executionpolicy RemoteSigned -file gen_big.ps1 |
12 changes: 12 additions & 0 deletions
12
tests/ImageSharp.Tests/TestImages/Formats/Tiff/gen_big.ps1
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
$Gm_Exe = "C:\Program Files\ImageMagick-7.0.8-Q16\magick.exe" | ||
$Source_Image = ".\jpeg444_big.jpg" | ||
$Output_Prefix = ".\jpeg444_big" | ||
|
||
& $Gm_Exe convert $Source_Image -compress None -type TrueColor $Output_Prefix"_rgb_uncompressed.tiff" | ||
& $Gm_Exe convert $Source_Image -compress LZW -type TrueColor $Output_Prefix"_rgb_lzw.tiff" | ||
& $Gm_Exe convert $Source_Image -compress RLE -type TrueColor $Output_Prefix"_rgb_packbits.tiff" | ||
& $Gm_Exe convert $Source_Image -compress JPEG -type TrueColor $Output_Prefix"_rgb_jpeg.tiff" | ||
& $Gm_Exe convert $Source_Image -compress Zip -type TrueColor $Output_Prefix"_rgb_deflate.tiff" | ||
|
||
& $Gm_Exe convert $Source_Image -compress None -type Grayscale $Output_Prefix"_grayscale_uncompressed.tiff" | ||
& $Gm_Exe convert $Source_Image -compress None -colors 256 $Output_Prefix"_palette_uncompressed.tiff" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.