// // Copyright (c) James Jackson-South and contributors. // Licensed under the Apache License, Version 2.0. // namespace ImageSharp.Tests.Processing.Transforms { using System; using System.IO; using System.Text; using ImageSharp.Processing; using ImageSharp.Processing.Processors; using Xunit; using Xunit.Abstractions; public class ResizeProfilingBenchmarks : MeasureFixture { public ResizeProfilingBenchmarks(ITestOutputHelper output) : base(output) { } public int ExecutionCount { get; set; } = 50; // [Theory] // Benchmark, enable manually! [InlineData(100, 100)] [InlineData(2000, 2000)] public void ResizeBicubic(int width, int height) { this.Measure(this.ExecutionCount, () => { using (var image = new Image(width, height)) { image.Resize(width / 4, height / 4); } }); } // [Fact] public void PrintWeightsData() { var proc = new ResizeProcessor(new BicubicResampler(), 200, 200); ResamplingWeightedProcessor.WeightsBuffer weights = proc.PrecomputeWeights(200, 500); var bld = new StringBuilder(); foreach (ResamplingWeightedProcessor.WeightsWindow window in weights.Weights) { Span span = window.GetWindowSpan(); for (int i = 0; i < window.Length; i++) { float value = span[i]; bld.Append(value); bld.Append("| "); } bld.AppendLine(); } File.WriteAllText("BicubicWeights.MD", bld.ToString()); // this.Output.WriteLine(bld.ToString()); } } }