Benchmarks reworked to save time on test data creation & have more comparable results against baseline.
This commit is contained in:
1 parent
73d3e32107
commit
bb878caa39
35 files changed
+586
-418
No files matched your search
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Add()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +15,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Add()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +26,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Add()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -41,7 +37,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Add()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_AddRangeWhenSourceIsArray()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -13,7 +11,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_AddRangeWhenSourceIsArray()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -21,7 +18,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_AddRangeWhenSourceIsArray()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +25,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_AddRangeWhenSourceIsArray()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_AddRangeWhenSourceIsIEnumerable()
|
||||
{
|
||||
var data = TestObjectsAsIEnumerable;
|
||||
@@ -13,7 +11,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_AddRangeWhenSourceIsIEnumerable()
|
||||
{
|
||||
var data = TestObjectsAsIEnumerable;
|
||||
@@ -21,7 +18,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_AddRangeWhenSourceIsIEnumerable()
|
||||
{
|
||||
var data = TestObjectsAsIEnumerable;
|
||||
@@ -29,7 +25,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_AddRangeWhenSourceIsIEnumerable()
|
||||
{
|
||||
var data = TestObjectsAsIEnumerable;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsRecyclableList;
|
||||
@@ -13,7 +11,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsPooledList;
|
||||
@@ -21,7 +18,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsRecyclableList;
|
||||
@@ -29,7 +25,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsRecyclableList;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_AddRangeWhenSourceIsList()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
@@ -13,7 +11,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_AddRangeWhenSourceIsList()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
@@ -21,7 +18,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_AddRangeWhenSourceIsList()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
@@ -29,7 +25,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_AddRangeWhenSourceIsList()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_AddRangeWhenSourceIsPooledList()
|
||||
{
|
||||
var data = TestObjectsAsPooledList;
|
||||
@@ -13,7 +11,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_AddRangeWhenSourceIsRecyclableArrayList()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableArrayList;
|
||||
@@ -21,7 +18,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_AddRangeWhenSourceIsRecyclableArrayList()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableArrayList;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_AddRange_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -14,7 +12,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_AddRange_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -23,7 +20,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_AddRange_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -32,7 +28,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_AddRange_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Add_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +15,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Add_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +26,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Add_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -41,7 +37,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Add_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_Contains_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -16,7 +13,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Contains_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -28,7 +24,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Contains_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -40,7 +35,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Contains_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -52,7 +46,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Contains_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_Contains_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -16,7 +13,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Contains_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -28,7 +24,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Contains_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -40,7 +35,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Contains_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -52,7 +46,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Contains_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,39 +1,31 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_Count()
|
||||
{
|
||||
var data = TestObjects;
|
||||
DoNothing(data.Length);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Count()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
DoNothing(data.Count);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Count()
|
||||
{
|
||||
var data = TestObjectsAsPooledList;
|
||||
DoNothing(data.Count);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Count()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableArrayList;
|
||||
DoNothing(data.Count);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Count()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Create()
|
||||
{
|
||||
var list = new List<long>();
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Create()
|
||||
{
|
||||
using var list = new PooledList<long>(ClearMode.Auto);
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Create()
|
||||
{
|
||||
using var list = new RecyclableArrayList<long>();
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Create()
|
||||
{
|
||||
using var list = new RecyclableList<long>();
|
||||
|
||||
@@ -1,39 +1,33 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_Create_WithCapacity()
|
||||
{
|
||||
var data = new long[TestObjectCount];
|
||||
DoNothing(data);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Create_WithCapacity()
|
||||
{
|
||||
var list = new List<long>(TestObjectCount);
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Create_WithCapacity()
|
||||
{
|
||||
using var list = new PooledList<long>(capacity: TestObjectCount, ClearMode.Auto);
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Create_WithCapacity()
|
||||
{
|
||||
using var list = new RecyclableArrayList<long>(TestObjectCount);
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Create_WithCapacity()
|
||||
{
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
[Benchmark(Baseline = false)]
|
||||
public void Array_GetItem()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -15,7 +12,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void List_GetItem()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
@@ -26,7 +22,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public void PooledList_GetItem()
|
||||
{
|
||||
var data = TestObjectsAsPooledList;
|
||||
@@ -37,7 +32,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_GetItem()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableArrayList;
|
||||
@@ -48,7 +42,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_GetItem()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
@@ -59,7 +52,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_GetItem_AsSpan()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
@@ -86,7 +78,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_GetItem_AsArray()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
@@ -114,7 +105,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_GetItem_AsForEach()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
@@ -124,7 +114,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_GetItem_AsWhile()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
[Benchmark(Baseline = false)]
|
||||
public void Array_IndexOf_AllItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -16,7 +13,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void List_IndexOf_AllItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -28,7 +24,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = true)]
|
||||
public void PooledList_IndexOf_AllItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -40,7 +35,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_IndexOf_AllItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -52,7 +46,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_IndexOf_AllItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -64,7 +57,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_LongIndexOf_AllItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_IndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -16,7 +13,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_IndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -28,7 +24,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_IndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -40,7 +35,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_IndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -52,7 +46,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_IndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -64,7 +57,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_LongIndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_IndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -16,7 +13,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_IndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -28,7 +24,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_IndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -40,7 +35,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_IndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -52,7 +46,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_IndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -64,7 +57,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_LongIndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,17 +1,13 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_LongCount()
|
||||
{
|
||||
var data = TestObjects;
|
||||
DoNothing(data.LongLength);
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_LongCount()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
|
||||
@@ -1,40 +1,66 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using System.Reflection;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
[MemoryDiagnoser]
|
||||
public partial class RecyclableCollectionsBenchmarks : BenchmarkBase
|
||||
public enum RecyclableCollectionsBenchmarkType
|
||||
{
|
||||
private long[]? _testArray;
|
||||
private RecyclableArrayList<long>? _testRecyclableArrayList;
|
||||
private RecyclableList<long>? _testRecyclableList;
|
||||
private PooledList<long>? _testPooledList;
|
||||
Add_WithCapacity, Add, AddRange_WithCapacity, AddRangeWhenSourceIsArray, AddRangeWhenSourceIsIEnumerable,
|
||||
AddRangeWhenSourceIsIList, AddRangeWhenSourceIsList, AddRangeWhenSourceIsSameType, Contains_FirstItems,
|
||||
Contains_LastItems, Count, Create_WithCapacity, Create, GetItem, IndexOf_AllItems, IndexOf_FirstItems,
|
||||
IndexOf_LastItems, LongCount, Remove_FirstItems, Remove_LastItems, RemoveAt_FirstItems, RemoveAt_LastItems,
|
||||
SetItem,
|
||||
}
|
||||
|
||||
public PooledList<long> TestObjectsAsPooledList => _testPooledList ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
|
||||
public partial class RecyclableCollectionsBenchmarks : RecyclableBenchmarkBase<RecyclableCollectionsBenchmarkSource>
|
||||
{
|
||||
[Params
|
||||
(
|
||||
RecyclableCollectionsBenchmarkType.Add_WithCapacity,
|
||||
RecyclableCollectionsBenchmarkType.Add,
|
||||
RecyclableCollectionsBenchmarkType.AddRange_WithCapacity,
|
||||
RecyclableCollectionsBenchmarkType.AddRangeWhenSourceIsArray,
|
||||
RecyclableCollectionsBenchmarkType.AddRangeWhenSourceIsIEnumerable,
|
||||
RecyclableCollectionsBenchmarkType.AddRangeWhenSourceIsIList,
|
||||
RecyclableCollectionsBenchmarkType.AddRangeWhenSourceIsList,
|
||||
RecyclableCollectionsBenchmarkType.AddRangeWhenSourceIsSameType,
|
||||
RecyclableCollectionsBenchmarkType.Contains_FirstItems,
|
||||
RecyclableCollectionsBenchmarkType.Contains_LastItems,
|
||||
RecyclableCollectionsBenchmarkType.Count,
|
||||
RecyclableCollectionsBenchmarkType.Create_WithCapacity,
|
||||
RecyclableCollectionsBenchmarkType.Create,
|
||||
RecyclableCollectionsBenchmarkType.GetItem,
|
||||
RecyclableCollectionsBenchmarkType.IndexOf_AllItems,
|
||||
RecyclableCollectionsBenchmarkType.IndexOf_FirstItems,
|
||||
RecyclableCollectionsBenchmarkType.IndexOf_LastItems,
|
||||
RecyclableCollectionsBenchmarkType.LongCount,
|
||||
RecyclableCollectionsBenchmarkType.Remove_FirstItems,
|
||||
RecyclableCollectionsBenchmarkType.Remove_LastItems,
|
||||
RecyclableCollectionsBenchmarkType.RemoveAt_FirstItems,
|
||||
RecyclableCollectionsBenchmarkType.RemoveAt_LastItems,
|
||||
RecyclableCollectionsBenchmarkType.SetItem
|
||||
)]
|
||||
|
||||
public override void Setup()
|
||||
{
|
||||
base.Setup();
|
||||
_testRecyclableArrayList = new(TestObjects, initialCapacity: TestObjectCount);
|
||||
_testRecyclableList = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
_testArray = TestObjects.ToArray();
|
||||
_testObjectsAsList = TestObjects.ToList();
|
||||
_testObjectsAsRecyclableArrayList = TestObjects.ToRecyclableArrayList();
|
||||
_testObjectsAsRecyclableList = TestObjects.ToRecyclableList();
|
||||
_testPooledList = new PooledList<long>(TestObjects, ClearMode.Always);
|
||||
}
|
||||
public RecyclableCollectionsBenchmarkType TestCase { get; set; } = RecyclableCollectionsBenchmarkType.IndexOf_AllItems;
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
_testRecyclableArrayList?.Dispose();
|
||||
_testRecyclableList?.Dispose();
|
||||
_testPooledList?.Dispose();
|
||||
TestObjectsAsRecyclableArrayList?.Dispose();
|
||||
_testObjectsAsRecyclableArrayList = default;
|
||||
_testObjectsAsRecyclableList = default;
|
||||
_testObjectsAsList = default;
|
||||
base.Cleanup();
|
||||
}
|
||||
[Params
|
||||
(
|
||||
RecyclableCollectionsBenchmarkSource.Array,
|
||||
RecyclableCollectionsBenchmarkSource.List,
|
||||
RecyclableCollectionsBenchmarkSource.PooledList,
|
||||
RecyclableCollectionsBenchmarkSource.RecyclableArrayList,
|
||||
RecyclableCollectionsBenchmarkSource.RecyclableList
|
||||
)]
|
||||
public override RecyclableCollectionsBenchmarkSource BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; }
|
||||
|
||||
[Params
|
||||
(
|
||||
RecyclableCollectionsBenchmarkSource.PooledList
|
||||
)]
|
||||
public override RecyclableCollectionsBenchmarkSource BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; }
|
||||
|
||||
protected override Action GetTestMethod(RecyclableCollectionsBenchmarkSource benchmarkType)
|
||||
=> (Action?) GetType().GetMethod($"{benchmarkType}_{TestCase}", BindingFlags.Instance | BindingFlags.Public)?.CreateDelegate(typeof(Action), this)
|
||||
?? throw CreateMethodNotFoundException($"{benchmarkType}_{TestCase}", GetType().FullName);
|
||||
}
|
||||
}
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_RemoveAt_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +15,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_RemoveAt_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +26,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_RemoveAt_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -41,7 +37,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_RemoveAt_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_RemoveAt_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +15,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_RemoveAt_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +26,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_RemoveAt_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -41,7 +37,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_RemoveAt_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Remove_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +15,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Remove_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +26,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Remove_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -41,7 +37,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Remove_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_Remove_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +15,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_Remove_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -29,7 +26,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_Remove_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -41,7 +37,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_Remove_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public partial class RecyclableCollectionsBenchmarks
|
||||
{
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void Array_SetItem()
|
||||
{
|
||||
var data = TestObjects;
|
||||
@@ -17,7 +13,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void List_SetItem()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
@@ -28,7 +23,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = true)]
|
||||
public void PooledList_SetItem()
|
||||
{
|
||||
var data = TestObjectsAsPooledList;
|
||||
@@ -39,7 +33,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableArrayList_SetItem()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableArrayList;
|
||||
@@ -50,7 +43,6 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
//[Benchmark(Baseline = false)]
|
||||
public void RecyclableList_SetItem()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
|
||||
Reference in new issue
Block a user