Browse Source

drop ComplexIntegrationTests, add ProfilingBenchmarks

af/merge-core
Anton Firszov 8 years ago
parent
commit
804b92f794
  1. 35
      tests/ImageSharp.Tests/ComplexIntegrationTests.cs
  2. 52
      tests/ImageSharp.Tests/ProfilingBenchmarks.cs

35
tests/ImageSharp.Tests/ComplexIntegrationTests.cs

@ -1,35 +0,0 @@
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
using Xunit;
namespace SixLabors.ImageSharp.Tests
{
/// <summary>
/// Might be useful to catch complex bugs
/// </summary>
public class ComplexIntegrationTests
{
[Theory]
[WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.Rgba32, 75, JpegSubsample.Ratio420)]
[WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.Rgba32, 75, JpegSubsample.Ratio420)]
[WithFile(TestImages.Jpeg.Baseline.Snake, PixelTypes.Rgba32, 75, JpegSubsample.Ratio444)]
[WithFile(TestImages.Jpeg.Baseline.Lake, PixelTypes.Rgba32, 75, JpegSubsample.Ratio444)]
public void LoadResizeSave<TPixel>(TestImageProvider<TPixel> provider, int quality, JpegSubsample subsample)
where TPixel : struct, IPixel<TPixel>
{
using (Image<TPixel> image = provider.GetImage(x => x.Resize(new ResizeOptions { Size = new Size(150, 100), Mode = ResizeMode.Max })))
{
image.MetaData.ExifProfile = null; // Reduce the size of the file
JpegEncoder options = new JpegEncoder { Subsample = subsample, Quality = quality };
provider.Utility.TestName += $"{subsample}_Q{quality}";
provider.Utility.SaveTestOutputFile(image, "png");
provider.Utility.SaveTestOutputFile(image, "jpg", options);
}
}
}
}

52
tests/ImageSharp.Tests/ProfilingBenchmarks.cs

@ -0,0 +1,52 @@
using System.IO;
using SixLabors.ImageSharp.Formats.Jpeg;
using SixLabors.ImageSharp.PixelFormats;
using SixLabors.ImageSharp.Processing;
using SixLabors.Primitives;
using Xunit;
using Xunit.Abstractions;
namespace SixLabors.ImageSharp.Tests
{
public class ProfilingBenchmarks : MeasureFixture
{
public const string SkipProfilingTests =
#if false
null;
#else
"Profiling benchmark, enable manually!";
#endif
public ProfilingBenchmarks(ITestOutputHelper output)
: base(output)
{
}
[Theory(Skip = SkipProfilingTests)]
[InlineData(TestImages.Jpeg.Baseline.Jpeg420Exif)]
public void LoadResizeSave(string imagePath)
{
var configuration = Configuration.CreateDefaultInstance();
configuration.MaxDegreeOfParallelism = 1;
byte[] imageBytes = TestFile.Create(imagePath).Bytes;
using (var ms = new MemoryStream())
{
this.Measure(30,
() =>
{
using (var image = Image.Load(configuration, imageBytes))
{
image.Mutate(x => x.Resize(image.Size() / 4));
image.SaveAsJpeg(ms);
}
ms.Seek(0, SeekOrigin.Begin);
});
}
}
}
}
Loading…
Cancel
Save