BoolOrComparePoc benchmarks added to confirm findings from RecyclableList.EnsureCapacity runs.
This commit is contained in:
1 parent
22060c4390
commit
ed11e42b48
2 files changed
+51
No files matched your search
@@ -0,0 +1,50 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
[MemoryDiagnoser]
|
||||
public class BoolOrComparePocBenchmarks
|
||||
{
|
||||
public static void Run()
|
||||
{
|
||||
var benchmark = new BoolOrComparePocBenchmarks();
|
||||
benchmark.Bool();
|
||||
benchmark.Compare();
|
||||
}
|
||||
|
||||
private static void DoNothing<T>(T result, [CallerMemberName] string? callerName = null)
|
||||
{
|
||||
//Console.WriteLine($"{callerName}: result = {result}");
|
||||
}
|
||||
|
||||
private bool _testBool = true;
|
||||
private int _blockSize = 8;
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void Bool()
|
||||
{
|
||||
if (_testBool)
|
||||
{
|
||||
DoNothing(_testBool);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoNothing(_testBool);
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void Compare()
|
||||
{
|
||||
if (_blockSize >= RecyclableDefaults.MinPooledArrayLength)
|
||||
{
|
||||
DoNothing(_testBool);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoNothing(_testBool);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -42,6 +42,7 @@ internal class Program
|
||||
_ = BenchmarkRunner.Run<ModuloPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<RefVsInstanceMemberPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<ArraySizeLimitPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<BoolOrComparePocBenchmarks>(BenchmarkConfig);
|
||||
}
|
||||
|
||||
private static void Main(string[] args)
|
||||
|
||||
Reference in new issue
Block a user