// Copyright (c) Six Labors. // Licensed under the Six Labors Split License. using BenchmarkDotNet.Attributes; namespace SixLabors.ImageSharp.Benchmarks.General.PixelConversion; /// /// Exposes every stateless packed-pixel shuffle operator for assembly inspection. /// /// /// Seven pixels expose the short-input and vector-tail paths. Seventeen pixels execute one /// full intrinsic group and leave one complete pixel for the scalar remainder, making every /// part of each generated traversal observable. /// [Config(typeof(Config.Analysis))] public class PackedPixelConversionAssembly { private byte[] source3; private byte[] source4; private byte[] destination3; private byte[] destination4; /// /// Gets or sets the number of pixels converted by each invocation. /// [Params(7, 17)] public int Count { get; set; } /// /// Populates the source buffers with deterministic non-uniform channel values. /// [GlobalSetup] public void Setup() { this.source3 = new byte[this.Count * 3]; this.source4 = new byte[this.Count * 4]; this.destination3 = new byte[this.Count * 3]; this.destination4 = new byte[this.Count * 4]; new Random(42).NextBytes(this.source3); new Random(42).NextBytes(this.source4); } /// /// Executes the WXYZ four-to-four operator. /// [Benchmark] public void Shuffle4Wxyz() => SimdUtils.Shuffle4(this.source4, this.destination4); /// /// Executes the WZYX four-to-four operator. /// [Benchmark] public void Shuffle4Wzyx() => SimdUtils.Shuffle4(this.source4, this.destination4); /// /// Executes the YZWX four-to-four operator. /// [Benchmark] public void Shuffle4Yzwx() => SimdUtils.Shuffle4(this.source4, this.destination4); /// /// Executes the ZYXW four-to-four operator. /// [Benchmark] public void Shuffle4Zyxw() => SimdUtils.Shuffle4(this.source4, this.destination4); /// /// Executes the XWZY four-to-four operator. /// [Benchmark] public void Shuffle4Xwzy() => SimdUtils.Shuffle4(this.source4, this.destination4); /// /// Executes the XYZ four-to-three operator. /// [Benchmark] public void Slice3Xyz() => SimdUtils.Shuffle4Slice3(this.source4, this.destination3); /// /// Executes the YZW four-to-three operator. /// [Benchmark] public void Slice3Yzw() => SimdUtils.Shuffle4Slice3(this.source4, this.destination3); /// /// Executes the WZY four-to-three operator. /// [Benchmark] public void Slice3Wzy() => SimdUtils.Shuffle4Slice3(this.source4, this.destination3); /// /// Executes the ZYX four-to-three operator. /// [Benchmark] public void Slice3Zyx() => SimdUtils.Shuffle4Slice3(this.source4, this.destination3); /// /// Executes the XYZW three-to-four operator. /// [Benchmark] public void Pad4Xyzw() => SimdUtils.Pad3Shuffle4(this.source3, this.destination4); /// /// Executes the WXYZ three-to-four operator. /// [Benchmark] public void Pad4Wxyz() => SimdUtils.Pad3Shuffle4(this.source3, this.destination4); /// /// Executes the WZYX three-to-four operator. /// [Benchmark] public void Pad4Wzyx() => SimdUtils.Pad3Shuffle4(this.source3, this.destination4); /// /// Executes the ZYXW three-to-four operator. /// [Benchmark] public void Pad4Zyxw() => SimdUtils.Pad3Shuffle4(this.source3, this.destination4); /// /// Executes the ZYX three-to-three operator. /// [Benchmark] public void Shuffle3Zyx() => SimdUtils.Shuffle3(this.source3, this.destination3); }