CollectionsBenchmarksBase renamed to DataDrivenBenchmarksBase. Small cleanup.

This commit is contained in:
mlemanczyk committed 2023-10-21 14:44:23 +02:00
1 parent f4a03406e3
commit a3e2f7621e
5 files changed
+29 -16

No files matched your search

@@ -1,5 +1,6 @@
using BenchmarkDotNet.Attributes;
using System.Numerics;
using System.Reflection;
namespace Collections.Benchmarks.Core
{
@@ -34,18 +35,14 @@ namespace Collections.Benchmarks.Core
public virtual int TestObjectCount { get; set; } = 0;
public virtual int TestObjectCountForSlowMethods { get; private set; }
protected static Exception CreateUnknownBenchmarkTypeException<T>(T benchmarkType)
{
return new InvalidOperationException($"******* UNKNOWN BENCHMARK TYPE {{{benchmarkType}}} *******");
}
protected static Exception CreateMethodNotFoundException(in string methodName, in string? className)
{
return new MethodAccessException($"******* METHOD {{{methodName}}} NOT FOUND IN CLASS {{{className}}} *******");
}
protected static Exception CreateUnknownBenchmarkTypeException<T>(T benchmarkType) => new InvalidOperationException($"******* UNKNOWN BENCHMARK TYPE {{{benchmarkType}}} *******");
protected static Exception CreateMethodNotFoundException(in string methodName, in string? className) => new MethodAccessException($"******* METHOD {{{methodName}}} NOT FOUND IN CLASS {{{className}}} *******");
protected virtual void PrepareData<T>(T benchmarkType) { }
protected virtual Action? GetTestMethod(TBenchmarkType? benchmarkType) => null;
protected virtual Action? GetTestMethod(TBenchmarkType? benchmarkType)
=> (Action?)GetType().GetMethod(GetTestMethodName(benchmarkType), BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public)?.CreateDelegate(typeof(Action), this) ?? throw CreateMethodNotFoundException(GetTestMethodName(benchmarkType), GetType().FullName);
protected virtual string GetTestMethodName(TBenchmarkType? benchmarkType) => $"{benchmarkType}";
[GlobalCleanup]
public virtual void Cleanup()
@@ -7,24 +7,27 @@
<OutputType>Library</OutputType>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Collections.Benchmarks.Core</PackageId>
<PackageVersion>0.0.1</PackageVersion>
<PackageVersion>0.0.4</PackageVersion>
<Authors>Marek Lemańczyk</Authors>
<Company>N/A</Company>
<Product>Collections.Benchmarks.Core</Product>
<PackageTags>Recyclable Array Pool List Sortable Sort Benchmark Benchmarks Collection Collections</PackageTags>
<Description>`Recyclable.Collections.Benchmarks.Core` project is a basic open source framework for performance measurements based on various collection types like `RecyclableList&lt;T&gt;`, `RecyclableLongList&lt;T&gt;`, `List&lt;T&gt;`, `SortableList&lt;T&gt;`, `PriorityQueue&lt;T&gt;` &amp; similar.</Description>
<Description>`Collections.Benchmarks.Core` project is a basic open source framework for performance measurements based on various collection types like `RecyclableList&lt;T&gt;`, `RecyclableLongList&lt;T&gt;`, `List&lt;T&gt;`, `SortableList&lt;T&gt;`, `PriorityQueue&lt;T&gt;` &amp; similar.</Description>
<PackageProjectUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core</PackageProjectUrl>
<RepositoryUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core</RepositoryUrl>
<Copyright>Marek Lemańczyk 2023</Copyright>
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
<PackageReadmeFile>README.md</PackageReadmeFile>
<RepositoryType>git</RepositoryType>
<PackageReleaseNotes>Initial version.</PackageReleaseNotes>
<PackageReleaseNotes>CollectionsBenchmarksBase renamed to DataDrivenBenchmarksBase. Small cleanup.</PackageReleaseNotes>
<Platforms>AnyCPU;x64</Platforms>
<PackageIconUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core/logo.png</PackageIconUrl>
<PackageIcon>logo.png</PackageIcon>
</PropertyGroup>
<ItemGroup>
<None Include="..\logo.png" Pack="true" PackagePath="" Link="logo.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="..\LICENSE.md" Pack="true" PackagePath="" Link="LICENSE.md">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
@@ -0,0 +1,13 @@
namespace Collections.Benchmarks.Core
{
public enum CollectionsBenchmarkType
{
Unknown, Add_WithCapacity, Add, AddRange_WithCapacity, AddRangeWhenSourceIsArray, AddRangeWhenSourceIsIEnumerable,
AddRangeWhenSourceIsIList, AddRangeWhenSourceIsList, AddRangeWhenSourceIsSameType, BinarySearch_BestAndWorstCases,
Contains_FirstItems, Contains_LastItems, ConvertAll, Count, Create_WithCapacity, Create, Exists_BestAndWorstCases,
Find_BestAndWorstCases, FindAll_BestAndWorstCases, FindLast_BestAndWorstCases, FindLastIndex_BestAndWorstCases,
ForEach, GetItem, IndexOf_BestAndWorstCases,IndexOf_FirstItems, IndexOf_LastItems, LongCount,
Remove_FirstItems, Remove_LastItems, RemoveAt_FirstItems, RemoveAt_LastItems,
SetItem, VersionedForEach
}
}
@@ -5,7 +5,7 @@ using Recyclable.Collections;
namespace Collections.Benchmarks.Core
{
[MemoryDiagnoser]
public class CollectionsBenchmarksBase<TBenchmarkType> : BaselineVsActualBenchmarkBase<TBenchmarkType>
public class DataDrivenBenchmarksBase<TTestCase> : BaselineVsActualBenchmarkBase<TTestCase>
{
protected int[]? _testObjects;
protected int[] TestObjects => _testObjects ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
@@ -62,7 +62,7 @@ namespace Collections.Benchmarks.Core
base.PrepareData(benchmarkType);
}
public override void Cleanup()
{
Console.WriteLine("******* GLOBAL CLEANUP *******");
BIN
View File
Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.0 KiB

After

Width:  |  Height:  |  Size: 14 KiB