CollectionsBenchmarksBase renamed to DataDrivenBenchmarksBase. Small cleanup.
This commit is contained in:
1 parent
f4a03406e3
commit
a3e2f7621e
5 files changed
+29
-16
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
using BenchmarkDotNet.Attributes;
|
using BenchmarkDotNet.Attributes;
|
||||||
using System.Numerics;
|
using System.Numerics;
|
||||||
|
using System.Reflection;
|
||||||
|
|
||||||
namespace Collections.Benchmarks.Core
|
namespace Collections.Benchmarks.Core
|
||||||
{
|
{
|
||||||
@@ -34,18 +35,14 @@ namespace Collections.Benchmarks.Core
|
|||||||
public virtual int TestObjectCount { get; set; } = 0;
|
public virtual int TestObjectCount { get; set; } = 0;
|
||||||
public virtual int TestObjectCountForSlowMethods { get; private set; }
|
public virtual int TestObjectCountForSlowMethods { get; private set; }
|
||||||
|
|
||||||
protected static Exception CreateUnknownBenchmarkTypeException<T>(T benchmarkType)
|
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}}} *******");
|
||||||
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 virtual void PrepareData<T>(T benchmarkType) { }
|
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]
|
[GlobalCleanup]
|
||||||
public virtual void Cleanup()
|
public virtual void Cleanup()
|
||||||
|
|||||||
@@ -7,24 +7,27 @@
|
|||||||
<OutputType>Library</OutputType>
|
<OutputType>Library</OutputType>
|
||||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||||
<PackageId>Collections.Benchmarks.Core</PackageId>
|
<PackageId>Collections.Benchmarks.Core</PackageId>
|
||||||
<PackageVersion>0.0.1</PackageVersion>
|
<PackageVersion>0.0.4</PackageVersion>
|
||||||
<Authors>Marek Lemańczyk</Authors>
|
<Authors>Marek Lemańczyk</Authors>
|
||||||
<Company>N/A</Company>
|
<Company>N/A</Company>
|
||||||
<Product>Collections.Benchmarks.Core</Product>
|
<Product>Collections.Benchmarks.Core</Product>
|
||||||
<PackageTags>Recyclable Array Pool List Sortable Sort Benchmark Benchmarks Collection Collections</PackageTags>
|
<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<T>`, `RecyclableLongList<T>`, `List<T>`, `SortableList<T>`, `PriorityQueue<T>` & similar.</Description>
|
<Description>`Collections.Benchmarks.Core` project is a basic open source framework for performance measurements based on various collection types like `RecyclableList<T>`, `RecyclableLongList<T>`, `List<T>`, `SortableList<T>`, `PriorityQueue<T>` & similar.</Description>
|
||||||
<PackageProjectUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core</PackageProjectUrl>
|
<PackageProjectUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core</PackageProjectUrl>
|
||||||
<RepositoryUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core</RepositoryUrl>
|
<RepositoryUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core</RepositoryUrl>
|
||||||
<Copyright>Marek Lemańczyk 2023</Copyright>
|
<Copyright>Marek Lemańczyk 2023</Copyright>
|
||||||
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
<PackageLicenseFile>LICENSE.md</PackageLicenseFile>
|
||||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||||
<RepositoryType>git</RepositoryType>
|
<RepositoryType>git</RepositoryType>
|
||||||
<PackageReleaseNotes>Initial version.</PackageReleaseNotes>
|
<PackageReleaseNotes>CollectionsBenchmarksBase renamed to DataDrivenBenchmarksBase. Small cleanup.</PackageReleaseNotes>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
<PackageIconUrl>https://github.com/mlemanczyk/Collections.Benchmarks.Core/logo.png</PackageIconUrl>
|
<PackageIcon>logo.png</PackageIcon>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<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">
|
<None Include="..\LICENSE.md" Pack="true" PackagePath="" Link="LICENSE.md">
|
||||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||||
</None>
|
</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
|
||||||
|
}
|
||||||
|
}
|
||||||
+2
-2
@@ -5,7 +5,7 @@ using Recyclable.Collections;
|
|||||||
namespace Collections.Benchmarks.Core
|
namespace Collections.Benchmarks.Core
|
||||||
{
|
{
|
||||||
[MemoryDiagnoser]
|
[MemoryDiagnoser]
|
||||||
public class CollectionsBenchmarksBase<TBenchmarkType> : BaselineVsActualBenchmarkBase<TBenchmarkType>
|
public class DataDrivenBenchmarksBase<TTestCase> : BaselineVsActualBenchmarkBase<TTestCase>
|
||||||
{
|
{
|
||||||
protected int[]? _testObjects;
|
protected int[]? _testObjects;
|
||||||
protected int[] TestObjects => _testObjects ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
|
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);
|
base.PrepareData(benchmarkType);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Cleanup()
|
public override void Cleanup()
|
||||||
{
|
{
|
||||||
Console.WriteLine("******* GLOBAL CLEANUP *******");
|
Console.WriteLine("******* GLOBAL CLEANUP *******");
|
||||||
Reference in new issue
Block a user