Benchmarks added & reorganized.

This commit is contained in:
mlemanczyk committed 2023-12-28 19:47:02 +01:00
1 parent ccf5c61dd0
commit a216c028a0
48 files changed
+13483 -363

No files matched your search

@@ -0,0 +1,48 @@
// Ignore Spelling: Poc
using BenchmarkDotNet.Attributes;
using Collections.Benchmarks.Core;
#pragma warning disable CA1822
namespace Recyclable.Collections.Benchmarks.POC
{
public class LessOperatorVsAndOperatorBenchmarks
{
private const int BitShift = 1 << 31;
private static readonly Random _rnd = new(1);
private static int _num = -Math.Abs(_rnd.Next());
public void Setup()
{
_num = -1;
Console.WriteLine($"*** We're comparing if {_num} is < 0 ***");
}
public void Cleanup() { }
[Benchmark(Baseline = true)]
public void CompareWithLess()
{
DoNothing.With(_num < 0);
}
[Benchmark]
public void CompareWithAnd()
{
DoNothing.With((_num & BitShift) != 0);
}
[Benchmark]
public void CompareWithEqual()
{
DoNothing.With(_num == -1);
}
[Benchmark]
public void CompareToZero()
{
DoNothing.With(_num == 0);
}
}
}