Merge branch 'main' of https://github.com/mlemanczyk/Recyclable.Collections
This commit is contained in:
commit
985d5d173f
9 files changed
+36
-35
No files matched your search
@@ -6,13 +6,13 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
public abstract class PocBenchmarkBase<TBenchmarkType>
|
||||
{
|
||||
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<TBenchmarkType>.Default.Equals(BaselineBenchmarkType, default))
|
||||
if (!EqualityComparer<TBenchmarkType>.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<TBenchmarkType>.Default.Equals(BaselineBenchmarkType, BenchmarkType))
|
||||
if (!EqualityComparer<TBenchmarkType>.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 *******");
|
||||
|
||||
Reference in new issue
Block a user