From 24a14f810bcd4ad9f3432aa099133dcaefe4b2af Mon Sep 17 00:00:00 2001 From: mlemanczyk Date: Tue, 11 Apr 2023 00:16:05 +0200 Subject: [PATCH] Additional benchmarks added. One-off quick smoke test added. --- Recyclable.Collections.Benchmarks/Program.cs | 48 ++++++++++++++------ 1 file changed, 35 insertions(+), 13 deletions(-) diff --git a/Recyclable.Collections.Benchmarks/Program.cs b/Recyclable.Collections.Benchmarks/Program.cs index 82b9a7a..8ff8914 100644 --- a/Recyclable.Collections.Benchmarks/Program.cs +++ b/Recyclable.Collections.Benchmarks/Program.cs @@ -29,20 +29,25 @@ internal class Program { var benchmark = new RecyclableCollectionsBenchmarks(); benchmark.Setup(); - foreach (var _ in Enumerable.Range(1, 1000)) - { - //benchmark.RecyclableList_Contains(); - //benchmark.RecyclableArrayList_AddRange_WithCapacity(); - //benchmark.RecyclableArrayList_Add_WithCapacity(); + //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_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(); } @@ -53,6 +58,23 @@ internal class Program ManualConfig.Create(DefaultConfig.Instance).WithOptions(ConfigOptions.DisableOptimizationsValidator | ConfigOptions.JoinSummary) ); + //var pool = ArrayPool.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();