diff --git a/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs b/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs index b741a94..c8560c2 100644 --- a/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/Benchmarks/RecyclableCollections.Benchmarks.cs @@ -17,8 +17,8 @@ namespace Recyclable.Collections.Benchmarks public RecyclableCollectionsBenchmarks() : base() { TestObjectCount = 1; - BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.List; - BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableLongList; + BaseDataType = RecyclableCollectionsBenchmarkSource.List; + DataType = RecyclableCollectionsBenchmarkSource.RecyclableLongList; } [Params @@ -54,7 +54,7 @@ namespace Recyclable.Collections.Benchmarks ( RecyclableCollectionsBenchmarkSource.List )] - public override RecyclableCollectionsBenchmarkSource BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; } + public override RecyclableCollectionsBenchmarkSource BaseDataType { get => base.BaseDataType; set => base.BaseDataType = value; } [Params ( @@ -64,7 +64,7 @@ namespace Recyclable.Collections.Benchmarks RecyclableCollectionsBenchmarkSource.RecyclableList, RecyclableCollectionsBenchmarkSource.RecyclableLongList )] - public override RecyclableCollectionsBenchmarkSource BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override RecyclableCollectionsBenchmarkSource DataType { get => base.DataType; set => base.DataType = value; } protected override Action? GetTestMethod(RecyclableCollectionsBenchmarkSource benchmarkType) => (Action?) GetType().GetMethod($"{benchmarkType}_{TestCase}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this) diff --git a/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs index ea60943..755b2a0 100644 --- a/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/BoolOrComparePoc.Benchmarks.cs @@ -12,7 +12,7 @@ namespace Recyclable.Collections.Benchmarks.POC public class BoolOrComparePocBenchmarks : PocBenchmarkBase { [Params(BoolOrComparePocBenchmarkType.Bool, BoolOrComparePocBenchmarkType.Compare)] - public override BoolOrComparePocBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override BoolOrComparePocBenchmarkType DataType { get => base.DataType; set => base.DataType = value; } [Params(8)] public override int TestObjectCount { get => base.TestObjectCount; set => base.TestObjectCount = value; } diff --git a/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs index c926998..11a2a5f 100644 --- a/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/DelegateVsComparerPoc.Benchmarks.cs @@ -38,10 +38,10 @@ namespace Recyclable.Collections.Benchmarks.POC DelegateVsComparerPocBenchmarkType.ListOfUnboxedStructs, DelegateVsComparerPocBenchmarkType.StaticFunc )] - public override DelegateVsComparerPocBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override DelegateVsComparerPocBenchmarkType DataType { get => base.DataType; set => base.DataType = value; } [Params(DelegateVsComparerPocBenchmarkType.Comparer)] - public override DelegateVsComparerPocBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; } + public override DelegateVsComparerPocBenchmarkType BaseDataType { get => base.BaseDataType; set => base.BaseDataType = value; } #region Dummy classes diff --git a/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs b/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs index 03805e5..a033a39 100644 --- a/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs +++ b/Recyclable.Collections.Benchmarks/POC/PocBenchmarkBase.cs @@ -6,13 +6,13 @@ namespace Recyclable.Collections.Benchmarks.POC { public abstract class PocBenchmarkBase { - public virtual TBenchmarkType? BenchmarkType { get; set; } - public virtual TBenchmarkType? BaselineBenchmarkType { get; set; } + public virtual TBenchmarkType? DataType { get; set; } + public virtual TBenchmarkType? BaseDataType { get; set; } private Action? _testMethod; protected Action TestMethod { - get => _testMethod ?? throw new OperationCanceledException("Skip - Custom benchmark run in progress"); + get => _testMethod ?? throw new OperationCanceledException("Skip - No actual defined"); set => _testMethod = value; } @@ -41,20 +41,21 @@ namespace Recyclable.Collections.Benchmarks.POC // [Params(192, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144)] // [Params(524_288, 786_432, 1_048_576)] // [Params(262_144, 393_216, 524_288)] - //[Params(850_000)] + // [Params(850_000)] // [Params(RecyclableDefaults.MaxPooledBlockSize)] // [Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 32, 40, 50, 60, 80, 90, 100, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144, 524288, 1048576, 10_000_000, 33_554_432, 50_000_000, 100_000_000)] [Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 32, 40, 50, 60, 80, 90, 100, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072)] //[Params(RecyclableDefaults.MinItemsCountForParallelization, 1_048_576, 2_097_152, 4_194_304, 8_388_608, 16_777_216, 33_554_432, RecyclableDefaults.MaxPooledBlockSize)] // [Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 30, 32, 40, 50, 60, 80, 90, 100, 128)] + // [Params(1, 10, 1024, 10240, RecyclableDefaults.MinPooledArrayLength, RecyclableDefaults.MinItemsCountForParallelization)] // [Params(RecyclableDefaults.MinItemsCountForParallelization * 3)] // [Params(1_048_576)] public virtual int TestObjectCount { get; set; } = 1; //33_554_432; //524_288; //131_072; public virtual int TestObjectCountForSlowMethods => (TestObjectCount / 2) + 1;// Math.Min(TestObjectCount, 131_072); - //[Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200)] - //[Params(10, 20, 50, 100)] - //[Params(1, 10)] + // [Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200)] + // [Params(10, 20, 50, 100)] + // [Params(1, 10)] public int Divider = 10; //public int BlockSize = 1_048_576;//int.MaxValue - 1; public int BlockSize => TestObjectCount switch @@ -96,23 +97,23 @@ namespace Recyclable.Collections.Benchmarks.POC [GlobalSetup] public virtual void Setup() { - Console.WriteLine($"******* SETTING UP TEST CASE FOR BENCHMARK {{{BenchmarkType}}} *******"); + Console.WriteLine($"******* SETTING UP TEST CASE FOR BENCHMARK {{{DataType}}} *******"); - if (!EqualityComparer.Default.Equals(BaselineBenchmarkType, default)) + if (!EqualityComparer.Default.Equals(BaseDataType, default)) { Console.WriteLine("******* SETTING UP BASELINE DATA *******"); - PrepareData(BaselineBenchmarkType); - _baselineMethod = GetTestMethod(BaselineBenchmarkType); + PrepareData(BaseDataType); + _baselineMethod = GetTestMethod(BaseDataType); } //~ We don't want to prepare data if baseline data is the same is benchmark data. //~ One would override another - waste of time & resources. - if (!EqualityComparer.Default.Equals(BaselineBenchmarkType, BenchmarkType)) + if (!EqualityComparer.Default.Equals(BaseDataType, DataType)) { Console.WriteLine("******* SETTING UP TEST CASE DATA *******"); - //~ If BaselineBenchmarkType == null, then we'll come here only if BaselineBenchmarkType != null. - PrepareData(BenchmarkType!); - _testMethod = GetTestMethod(BenchmarkType); + //~ If BaseDataType == null, then we'll come here only if DataType != null. + PrepareData(DataType!); + _testMethod = GetTestMethod(DataType); } Console.WriteLine("******* DATA PREPARED *******"); diff --git a/Recyclable.Collections.Benchmarks/POC/RecyclableLongListPoc.Benchmarks.cs b/Recyclable.Collections.Benchmarks/POC/RecyclableLongListPoc.Benchmarks.cs index 0a067a8..4c72e88 100644 --- a/Recyclable.Collections.Benchmarks/POC/RecyclableLongListPoc.Benchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/RecyclableLongListPoc.Benchmarks.cs @@ -23,11 +23,11 @@ namespace Recyclable.Collections.Benchmarks.POC public partial class RecyclableLongListPocBenchmarks : PocBenchmarkBase { [Params(RecyclableLongListPocBenchmarkType.IndexOf)] - public override RecyclableLongListPocBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override RecyclableLongListPocBenchmarkType DataType { get => base.DataType; set => base.DataType = value; } // [Params(BenchmarkType.Array, BenchmarkType.List, BenchmarkType.RecyclableList, BenchmarkType.RecyclableLongList)] [Params(RecyclableLongListPocBenchmarkType.IndexOf_PooledList)] - public override RecyclableLongListPocBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; } + public override RecyclableLongListPocBenchmarkType BaseDataType { get => base.BaseDataType; set => base.BaseDataType = value; } private long[]? _testArray; public long[] TestObjects => _testArray ?? throw new NullReferenceException("Something is wrong and test objects are null"); @@ -131,7 +131,7 @@ namespace Recyclable.Collections.Benchmarks.POC { base.PrepareData(benchmarkType); - switch (BenchmarkType) + switch (benchmarkType) { case RecyclableLongListPocBenchmarkType.IndexOfV1: _testRecyclableLongListIndexOfV1 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount); diff --git a/Recyclable.Collections.Benchmarks/POC/RoundBenchmarks.cs b/Recyclable.Collections.Benchmarks/POC/RoundBenchmarks.cs index d3b8223..1aa35b4 100644 --- a/Recyclable.Collections.Benchmarks/POC/RoundBenchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/RoundBenchmarks.cs @@ -12,10 +12,10 @@ namespace Recyclable.Collections.Benchmarks.POC public class RoundBenchmarks : PocBenchmarkBase { [Params(RoundBenchmarkType.MathFloor)] - public override RoundBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; } + public override RoundBenchmarkType BaseDataType { get => base.BaseDataType; set => base.BaseDataType = value; } [Params(RoundBenchmarkType.MathRound, RoundBenchmarkType.WithTypecasting)] - public override RoundBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override RoundBenchmarkType DataType { get => base.DataType; set => base.DataType = value; } private const double OptimalParallelSearchStep = 0.329; diff --git a/Recyclable.Collections.Benchmarks/POC/SpanVsArrayBenchmarks.cs b/Recyclable.Collections.Benchmarks/POC/SpanVsArrayBenchmarks.cs index b270c14..3a45b2c 100644 --- a/Recyclable.Collections.Benchmarks/POC/SpanVsArrayBenchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/SpanVsArrayBenchmarks.cs @@ -21,11 +21,11 @@ namespace Recyclable.Collections.Benchmarks.POC SpanVsArrayBenchmarkType.ArrayGetWithVar, SpanVsArrayBenchmarkType.SpanGet, SpanVsArrayBenchmarkType.ArraySetWithField, SpanVsArrayBenchmarkType.ArraySetWithVar, SpanVsArrayBenchmarkType.SpanSet )] - public override SpanVsArrayBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override SpanVsArrayBenchmarkType DataType { get => base.DataType; set => base.DataType = value; } [Params(SpanVsArrayBenchmarkType.ArrayGetWithField)] // [Params(SpanVsArrayBenchmarkType.ArraySetWithField)] - public override SpanVsArrayBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; } + public override SpanVsArrayBenchmarkType BaseDataType { get => base.BaseDataType; set => base.BaseDataType = value; } protected override Action GetTestMethod(SpanVsArrayBenchmarkType benchmarkType) => benchmarkType switch { diff --git a/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs b/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs index b2b3e4a..9cb232e 100644 --- a/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs +++ b/Recyclable.Collections.Benchmarks/POC/WhenParallelSearchBenchmarks.cs @@ -83,10 +83,10 @@ namespace Recyclable.Collections.Benchmarks.POC public object? ItemToFind { get; set; } [Params(WhenParallelSearchBenchmarkType.IndexOfParallel)] - public override WhenParallelSearchBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } + public override WhenParallelSearchBenchmarkType DataType { get => base.DataType; set => base.DataType = value; } [Params(WhenParallelSearchBenchmarkType.IndexOfSequentially)] - public override WhenParallelSearchBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; } + public override WhenParallelSearchBenchmarkType BaseDataType { get => base.BaseDataType; set => base.BaseDataType = value; } private long DoLongIndexOfSequentially() { @@ -304,7 +304,7 @@ namespace Recyclable.Collections.Benchmarks.POC ItemToFind ??= _testData.Last(); } - protected override Action? GetTestMethod(WhenParallelSearchBenchmarkType benchmarkType) => BenchmarkType switch + protected override Action? GetTestMethod(WhenParallelSearchBenchmarkType benchmarkType) => benchmarkType switch { WhenParallelSearchBenchmarkType.IndexOfSequentially => IndexOfSequentially, WhenParallelSearchBenchmarkType.IndexOfParallel => IndexOfParallel, diff --git a/Recyclable.Collections.Benchmarks/Program.cs b/Recyclable.Collections.Benchmarks/Program.cs index c77c085..26a8f3e 100644 --- a/Recyclable.Collections.Benchmarks/Program.cs +++ b/Recyclable.Collections.Benchmarks/Program.cs @@ -28,9 +28,9 @@ public static class Program //foreach (var _ in Enumerable.Range(1, 1000)) //{ - // benchmark.RecyclableLongList_Remove_FirstItems(); - // benchmark.RecyclableLongList_RemoveAt_LastItems(); - // benchmark.List_RemoveAt_LastItems(); + // benchmark.RecyclableLongList_Remove_FirstItems(); + // benchmark.RecyclableLongList_RemoveAt_LastItems(); + // benchmark.List_RemoveAt_LastItems(); //} //benchmark.Cleanup();