📷 A modern, cross-platform, 2D Graphics library for .NET
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

42 lines
976 B

// Copyright (c) Six Labors.
// Licensed under the Apache License, Version 2.0.
using System;
using BenchmarkDotNet.Attributes;
namespace SixLabors.ImageSharp.Benchmarks.General.BasicMath
{
public class ClampSpan
{
private static readonly int[] A = new int[2048];
private static readonly int[] B = new int[2048];
public void Setup()
{
var r = new Random();
for (int i = 0; i < A.Length; i++)
{
int x = r.Next();
A[i] = x;
B[i] = x;
}
}
[Benchmark(Baseline = true)]
public void ClampNoIntrinsics()
{
for (int i = 0; i < A.Length; i++)
{
ref int x = ref A[i];
x = Numerics.Clamp(x, 64, 128);
}
}
[Benchmark]
public void ClampVectorIntrinsics()
{
Numerics.Clamp(B, 64, 128);
}
}
}