Benchmarks mostly reorganized & cleaned up. Simplified for re-runs.

This commit is contained in:
mlemanczyk committed 2023-04-11 16:42:06 +02:00
1 parent eae5cb4452
commit 2d7e62df72
12 files changed
+2045 -1040

No files matched your search

+31 -77
View File
@@ -1,100 +1,54 @@
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Running;
using Recyclable.Collections.Benchmarks;
//BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "-f*" });
//BenchmarkRunner.Run<RefVsInstanceMemberBenchmarks>();
using Recyclable.Collections.Benchmarks.POC;
internal class Program
{
static void RunModuloBenchmarks()
static IConfig BenchmarkConfig { get; } = ManualConfig.Create(DefaultConfig.Instance).WithOptions(ConfigOptions.DisableOptimizationsValidator | ConfigOptions.JoinSummary);
static void RunAssemblyBenchmarks()
{
var benchmark = new ModuloBenchmarks();
//benchmark.AddWithFor();
//benchmark.DividerAndModulusOperator();
//benchmark.MathDivRem();
//benchmark.SubtracWithWhile();
//benchmark.XDivYMulX();
//benchmark.XDivYMulXWithLocalVar();
//benchmark.AddWithForOptimized();
//benchmark.MixedApproachWithForLoopOptimized();
//benchmark.MixedApproachWithSubtractWithWhile();
benchmark.MixedApproachWithSubtractWithWhileAsVector();
_ = BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "-f*" });
}
static void RunBenchmark()
private static void RunRecyclableCollectionsBenchmarks()
{
var benchmark = new RecyclableCollectionsBenchmarks();
benchmark.Setup();
_ = BenchmarkRunner.Run<RecyclableCollectionsBenchmarks>(BenchmarkConfig);
}
static void RunSelectedBenchmarks()
{
// ****************
// *** Template ***
// ****************
//var benchmark = new RecyclableCollectionsBenchmarks();
//benchmark.Setup();
//foreach (var _ in Enumerable.Range(1, 1000))
//{
//benchmark.RecyclableList_Contains();
//benchmark.RecyclableArrayList_AddRange_WithCapacity();
//benchmark.RecyclableArrayList_Add_WithCapacity();
//benchmark.RecyclableList_Create();
//benchmark.RecyclableList_Create_WithCapacity();
//benchmark.RecyclableList_Add();
//benchmark.RecyclableList_Add_WithCapacity();
//benchmark.RecyclableList_Contains_LastItems();
//benchmark.RecyclableList_IndexOf_FirstItems();
//benchmark.RecyclableList_AddRangeWhenSourceIsList();
//benchmark.RecyclableList_Remove_FirstItems();
//benchmark.RecyclableList_RemoveAt_LastItems();
//benchmark.RecyclableList_EnsureCapacity_New_ByBlockSize();
benchmark.RecyclableList_EnsureCapacity_ByPowOf2();
//benchmark.List_RemoveAt_LastItems();
//}
benchmark.Cleanup();
//benchmark.Cleanup();
}
static void RunPocBenchmarks()
{
_ = BenchmarkRunner.Run<RecyclableListPocBenchmarks>(BenchmarkConfig);
_ = BenchmarkRunner.Run<DelegateVsComparerPocBenchmarks>(BenchmarkConfig);
_ = BenchmarkRunner.Run<ModuloPocBenchmarks>(BenchmarkConfig);
_ = BenchmarkRunner.Run<RefVsInstanceMemberPocBenchmarks>(BenchmarkConfig);
_ = BenchmarkRunner.Run<ArraySizeLimitPocBenchmarks>(BenchmarkConfig);
}
private static void Main(string[] args)
{
BenchmarkRunner.Run<RecyclableCollectionsBenchmarks>(
ManualConfig.Create(DefaultConfig.Instance).WithOptions(ConfigOptions.DisableOptimizationsValidator | ConfigOptions.JoinSummary)
);
//var pool = ArrayPool<object>.Shared;
//for (long bufferSize = int.MaxValue / 2; bufferSize <= int.MaxValue; bufferSize += 100_000_000)
//{
// try
// {
// Console.WriteLine($"Allocating {bufferSize}");
// var arr = pool.Rent((int)bufferSize);
// pool.Return(arr);
// GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true);
// }
// catch (Exception)
// {
// Console.WriteLine($"Error during array creation. {nameof(bufferSize)} = {bufferSize}");
// throw;
// }
//}
//RunBenchmark();
//BenchmarkRunner.Run<ModuloBenchmarks>(
// ManualConfig.Create(DefaultConfig.Instance).WithOptions(ConfigOptions.DisableOptimizationsValidator | ConfigOptions.JoinSummary)
//);
//RunModuloBenchmarks();
RunRecyclableCollectionsBenchmarks();
//RunPocBenchmarks();
//RunSelectedBenchmarks();
//RunAssemblyBenchmarks();
}
}
// benchmark.Setup();
// benchmark.Cleanup();
//benchmark.Setup();
//benchmark.Cleanup();
//}
//BenchmarkRunner.Run<DelegateVsComparerBenchmark>();
//var tests = new ListVsLinkedListBenchmark();
//tests.RecyclableList();