Added support for running benchmarks without baseline.

This commit is contained in:
mlemanczyk committed 2023-05-25 19:11:09 +02:00
1 parent 853a69fa4d
commit 8bef46f1cf
3 files changed
+5 -2

No files matched your search

@@ -66,7 +66,7 @@ namespace Recyclable.Collections.Benchmarks
)] )]
public override RecyclableCollectionsBenchmarkSource BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; } public override RecyclableCollectionsBenchmarkSource BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; }
protected override Action GetTestMethod(RecyclableCollectionsBenchmarkSource benchmarkType) protected override Action? GetTestMethod(RecyclableCollectionsBenchmarkSource benchmarkType)
=> (Action?) GetType().GetMethod($"{benchmarkType}_{TestCase}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this) => (Action?) GetType().GetMethod($"{benchmarkType}_{TestCase}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this)
?? throw CreateMethodNotFoundException($"{benchmarkType}_{TestCase}", GetType().FullName); ?? throw CreateMethodNotFoundException($"{benchmarkType}_{TestCase}", GetType().FullName);
} }
@@ -94,7 +94,7 @@ namespace Recyclable.Collections.Benchmarks.POC
{ {
Console.WriteLine($"******* SETTING UP TEST CASE FOR BENCHMARK {{{BenchmarkType}}} *******"); Console.WriteLine($"******* SETTING UP TEST CASE FOR BENCHMARK {{{BenchmarkType}}} *******");
if (BaselineBenchmarkType != null) if (!EqualityComparer<TBenchmarkType>.Default.Equals(BaselineBenchmarkType, default))
{ {
Console.WriteLine("******* SETTING UP BASELINE DATA *******"); Console.WriteLine("******* SETTING UP BASELINE DATA *******");
PrepareData(BaselineBenchmarkType); PrepareData(BaselineBenchmarkType);
@@ -52,6 +52,9 @@ namespace Recyclable.Collections.Benchmarks
Console.WriteLine($"******* PREPARING DATA FOR {benchmarkType} *******"); Console.WriteLine($"******* PREPARING DATA FOR {benchmarkType} *******");
switch (benchmarkType) switch (benchmarkType)
{ {
case RecyclableCollectionsBenchmarkSource.Unknown:
break;
case RecyclableCollectionsBenchmarkSource.Array: case RecyclableCollectionsBenchmarkSource.Array:
_testObjects ??= DataGenerator.EnumerateTestObjects(TestObjectCount); _testObjects ??= DataGenerator.EnumerateTestObjects(TestObjectCount);
break; break;