RecyclableList renamed to RecyclableLongList.
This commit is contained in:
1 parent
0894dbd4bf
commit
9429218c62
45 files changed
+576
-532
No files matched your search
@@ -37,11 +37,11 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_Add()
|
||||
public void RecyclableLongList_Add()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var dataCount = TestObjectCount;
|
||||
using var list = new RecyclableList<long>();
|
||||
using var list = new RecyclableLongList<long>();
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
list.Add(data[i]);
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
public void RecyclableList_AddRangeWhenSourceIsArray()
|
||||
public void RecyclableLongList_AddRangeWhenSourceIsArray()
|
||||
{
|
||||
var data = TestObjects;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
list.AddRange(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
public void RecyclableList_AddRangeWhenSourceIsIEnumerable()
|
||||
public void RecyclableLongList_AddRangeWhenSourceIsIEnumerable()
|
||||
{
|
||||
var data = TestObjectsAsIEnumerable;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
list.AddRange(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
public void List_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsRecyclableList;
|
||||
var data = (IList<long>)TestObjectsAsRecyclableLongList;
|
||||
var list = new List<long>();
|
||||
list.AddRange(data);
|
||||
}
|
||||
@@ -20,15 +20,15 @@ namespace Recyclable.Collections.Benchmarks
|
||||
|
||||
public void RecyclableArrayList_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsRecyclableList;
|
||||
var data = (IList<long>)TestObjectsAsRecyclableLongList;
|
||||
using var list = new RecyclableArrayList<long>();
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
public void RecyclableList_AddRangeWhenSourceIsIList()
|
||||
public void RecyclableLongList_AddRangeWhenSourceIsIList()
|
||||
{
|
||||
var data = (IList<long>)TestObjectsAsRecyclableList;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
var data = (IList<long>)TestObjectsAsRecyclableLongList;
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
list.AddRange(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,10 +25,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
public void RecyclableList_AddRangeWhenSourceIsList()
|
||||
public void RecyclableLongList_AddRangeWhenSourceIsList()
|
||||
{
|
||||
var data = TestObjectsAsList;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
list.AddRange(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
public void RecyclableList_AddRangeWhenSourceIsRecyclableArrayList()
|
||||
public void RecyclableLongList_AddRangeWhenSourceIsRecyclableArrayList()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableArrayList;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
list.AddRange(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,11 +28,11 @@ namespace Recyclable.Collections.Benchmarks
|
||||
list.AddRange(data);
|
||||
}
|
||||
|
||||
public void RecyclableList_AddRange_WithCapacity()
|
||||
public void RecyclableLongList_AddRange_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var dataCount = TestObjectCount;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: dataCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: dataCount);
|
||||
list.AddRange(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,11 +37,11 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_Add_WithCapacity()
|
||||
public void RecyclableLongList_Add_WithCapacity()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var dataCount = TestObjectCount;
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: dataCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: dataCount);
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
list.Add(data[i]);
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_Contains_FirstItems()
|
||||
public void RecyclableLongList_Contains_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCount / 10 > 0 ? TestObjectCount / 10 : TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_Contains_LastItems()
|
||||
public void RecyclableLongList_Contains_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCount / 10 > 0 ? TestObjectCount / 10 : TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -26,9 +26,9 @@
|
||||
DoNothing(data.Count);
|
||||
}
|
||||
|
||||
public void RecyclableList_Count()
|
||||
public void RecyclableLongList_Count()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
DoNothing(data.Count);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,9 +22,9 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
public static void RecyclableList_Create()
|
||||
public static void RecyclableLongList_Create()
|
||||
{
|
||||
using var list = new RecyclableList<long>();
|
||||
using var list = new RecyclableLongList<long>();
|
||||
DoNothing(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,9 +28,9 @@ namespace Recyclable.Collections.Benchmarks
|
||||
DoNothing(list);
|
||||
}
|
||||
|
||||
public void RecyclableList_Create_WithCapacity()
|
||||
public void RecyclableLongList_Create_WithCapacity()
|
||||
{
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
DoNothing(list);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,9 +42,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_GetItem()
|
||||
public void RecyclableLongList_GetItem()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -52,9 +52,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_GetItem_AsSpan()
|
||||
public void RecyclableLongList_GetItem_AsSpan()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
int blockSize = data.BlockSize;
|
||||
int nextItemBlockIndex = data.NextItemBlockIndex;
|
||||
|
||||
@@ -78,9 +78,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_GetItem_AsArray()
|
||||
public void RecyclableLongList_GetItem_AsArray()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
int blockSize = data.BlockSize;
|
||||
int nextItemBlockIndex = data.NextItemBlockIndex;
|
||||
|
||||
@@ -105,18 +105,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_GetItem_AsForEach()
|
||||
public void RecyclableLongList_GetItem_AsForEach()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
foreach (var item in data)
|
||||
{
|
||||
DoNothing(item);
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_GetItem_AsWhile()
|
||||
public void RecyclableLongList_GetItem_AsWhile()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
long dataCount = TestObjectCount;
|
||||
if (dataCount == 0)
|
||||
{
|
||||
|
||||
@@ -50,10 +50,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOf_BestAndWorstCases()
|
||||
public void RecyclableLongList_IndexOf_BestAndWorstCases()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCountForSlowMethods;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -62,10 +62,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_LongIndexOf_BestAndWorstCases()
|
||||
public void RecyclableLongList_LongIndexOf_BestAndWorstCases()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCountForSlowMethods;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOf_FirstItems()
|
||||
public void RecyclableLongList_IndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCountForSlowMethods;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -57,10 +57,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_LongIndexOf_FirstItems()
|
||||
public void RecyclableLongList_LongIndexOf_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCountForSlowMethods;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -46,10 +46,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOf_LastItems()
|
||||
public void RecyclableLongList_IndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCountForSlowMethods;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -57,10 +57,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_LongIndexOf_LastItems()
|
||||
public void RecyclableLongList_LongIndexOf_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCountForSlowMethods;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -8,9 +8,9 @@
|
||||
DoNothing(data.LongLength);
|
||||
}
|
||||
|
||||
public void RecyclableList_LongCount()
|
||||
public void RecyclableLongList_LongCount()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
DoNothing(data.LongCount);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace Recyclable.Collections.Benchmarks
|
||||
{
|
||||
TestObjectCount = 1;
|
||||
BaselineBenchmarkType = RecyclableCollectionsBenchmarkSource.PooledList;
|
||||
BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableList;
|
||||
BenchmarkType = RecyclableCollectionsBenchmarkSource.RecyclableLongList;
|
||||
}
|
||||
|
||||
[Params
|
||||
@@ -62,7 +62,7 @@ namespace Recyclable.Collections.Benchmarks
|
||||
RecyclableCollectionsBenchmarkSource.List,
|
||||
RecyclableCollectionsBenchmarkSource.PooledList,
|
||||
RecyclableCollectionsBenchmarkSource.RecyclableArrayList,
|
||||
RecyclableCollectionsBenchmarkSource.RecyclableList
|
||||
RecyclableCollectionsBenchmarkSource.RecyclableLongList
|
||||
)]
|
||||
public override RecyclableCollectionsBenchmarkSource BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; }
|
||||
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_RemoveAt_FirstItems()
|
||||
public void RecyclableLongList_RemoveAt_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
using var list = new RecyclableList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
var dataCount = TestObjectCount / 10 > 0 ? TestObjectCount / 10 : TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_RemoveAt_LastItems()
|
||||
public void RecyclableLongList_RemoveAt_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
using var list = new RecyclableList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
var dataCount = TestObjectCount / 10 > 0 ? TestObjectCount / 10 : TestObjectCount;
|
||||
for (var i = data.Length - 1; i > data.Length - dataCount - 1; i--)
|
||||
{
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_Remove_FirstItems()
|
||||
public void RecyclableLongList_Remove_FirstItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
using var list = new RecyclableList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
var dataCount = TestObjectCount / 10 > 0 ? TestObjectCount / 10 : TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -37,10 +37,10 @@ namespace Recyclable.Collections.Benchmarks
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_Remove_LastItems()
|
||||
public void RecyclableLongList_Remove_LastItems()
|
||||
{
|
||||
var data = TestObjects;
|
||||
using var list = new RecyclableList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(data, minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
var dataCount = TestObjectCount / 10 > 0 ? TestObjectCount / 10 : TestObjectCount;
|
||||
for (var i = data.Length - 1; i > data.Length - dataCount - 1; i--)
|
||||
{
|
||||
|
||||
@@ -43,9 +43,9 @@
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_SetItem()
|
||||
public void RecyclableLongList_SetItem()
|
||||
{
|
||||
var data = TestObjectsAsRecyclableList;
|
||||
var data = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
|
||||
@@ -1,157 +0,0 @@
|
||||
using System.Reflection;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Recyclable.Collections.Benchmarks.Core;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
public enum RecyclableListPocBenchmarkType
|
||||
{
|
||||
IndexOfV1,
|
||||
IndexOfV2,
|
||||
IndexOfV3,
|
||||
IndexOfV4,
|
||||
IndexOf_PooledList,
|
||||
IndexOf,
|
||||
EnsureCapacity_ByPowOf2,
|
||||
EnsureCapacityV1_ByPowOf2,
|
||||
EnsureCapacityV2_ByPowOf2,
|
||||
EnsureCapacityV3_ByPowOf2,
|
||||
}
|
||||
|
||||
[MemoryDiagnoser]
|
||||
public partial class RecyclableListPocBenchmarks : PocBenchmarkBase<RecyclableListPocBenchmarkType>
|
||||
{
|
||||
[Params(RecyclableListPocBenchmarkType.IndexOf)]
|
||||
public override RecyclableListPocBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; }
|
||||
|
||||
// [Params(BenchmarkType.Array, BenchmarkType.List, BenchmarkType.RecyclableArrayList, BenchmarkType.RecyclableList)]
|
||||
[Params(RecyclableListPocBenchmarkType.IndexOf_PooledList)]
|
||||
public override RecyclableListPocBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; }
|
||||
|
||||
private long[]? _testArray;
|
||||
public long[] TestObjects => _testArray ?? throw new NullReferenceException("Something is wrong and test objects are null");
|
||||
|
||||
public RecyclableList<long> TestObjectsAsRecyclableList => _testRecyclableList ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableList<long>)} is null");
|
||||
private RecyclableListIndexOfV1<long>? _testRecyclableListIndexOfV1;
|
||||
internal RecyclableListIndexOfV1<long> TestObjectsAsRecyclableListIndexOfV1 => _testRecyclableListIndexOfV1 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableListIndexOfV1<long>)} is null");
|
||||
private RecyclableListIndexOfV2<long>? _testRecyclableListIndexOfV2;
|
||||
private RecyclableList<long>? _testRecyclableList;
|
||||
internal RecyclableListIndexOfV2<long> TestObjectsAsRecyclableListIndexOfV2 => _testRecyclableListIndexOfV2 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableListIndexOfV2<long>)} is null");
|
||||
private RecyclableListIndexOfV3<long>? _testRecyclableListIndexOfV3;
|
||||
internal RecyclableListIndexOfV3<long> TestObjectsAsRecyclableListIndexOfV3 => _testRecyclableListIndexOfV3 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableListIndexOfV3<long>)} is null");
|
||||
private RecyclableListIndexOfV4<long>? _testRecyclableListIndexOfV4;
|
||||
internal RecyclableListIndexOfV4<long> TestObjectsAsRecyclableListIndexOfV4 => _testRecyclableListIndexOfV4 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableListIndexOfV4<long>)} is null");
|
||||
private PooledList<long>? _testPooledList;
|
||||
internal PooledList<long> TestPooledList => _testPooledList ?? throw new NullReferenceException($"Something is wrong and {nameof(PooledList<long>)} is null");
|
||||
|
||||
private static readonly MethodInfo _ensureCapacityNewFunc;
|
||||
private static readonly MethodInfo _ensureCapacityV1Func;
|
||||
private static readonly MethodInfo _ensureCapacityV2Func;
|
||||
private static readonly MethodInfo _ensureCapacityV3Func;
|
||||
|
||||
static RecyclableListPocBenchmarks()
|
||||
{
|
||||
_ensureCapacityNewFunc = typeof(RecyclableList<long>).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.NonPublic)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableList<long>)}");
|
||||
|
||||
_ensureCapacityV1Func = typeof(RecyclableListV1<long>).GetMethod("EnsureCapacity", BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableListV1<long>)}");
|
||||
|
||||
_ensureCapacityV2Func = typeof(RecyclableListV2<long>).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.Public)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableListV2<long>)}");
|
||||
|
||||
_ensureCapacityV3Func = typeof(RecyclableListV3<long>).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.NonPublic)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableListV3<long>)}");
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
var benchmark = new RecyclableListPocBenchmarks();
|
||||
benchmark.Setup();
|
||||
// benchmark.RecyclableList_EnsureCapacity_ByPowOf2();
|
||||
// benchmark.RecyclableList_EnsureCapacityV1_ByPowOf2();
|
||||
// benchmark.RecyclableList_EnsureCapacityV2_ByPowOf2();
|
||||
// benchmark.RecyclableList_EnsureCapacityV3_ByPowOf2();
|
||||
// benchmark.RecyclableList_EnsureCapacity_ByBlockSize();
|
||||
// benchmark.RecyclableList_EnsureCapacityV1_ByBlockSize();
|
||||
// benchmark.RecyclableList_EnsureCapacityV2_ByBlockSize();
|
||||
// benchmark.RecyclableList_EnsureCapacityV3_ByBlockSize();
|
||||
benchmark.RecyclableList_IndexOf();
|
||||
benchmark.RecyclableList_IndexOfV1();
|
||||
benchmark.RecyclableList_IndexOfV2();
|
||||
benchmark.RecyclableList_IndexOfV3();
|
||||
benchmark.RecyclableList_IndexOfV4();
|
||||
benchmark.Cleanup();
|
||||
}
|
||||
|
||||
public override void Setup()
|
||||
{
|
||||
Console.WriteLine("******* SETTING UP EXPECTED RESULTS DATA *******");
|
||||
_testArray = DataGenerator.EnumerateTestObjects(TestObjectCount);
|
||||
|
||||
base.Setup();
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
_testArray = null;
|
||||
_testRecyclableList?.Dispose();
|
||||
_testRecyclableList = null;
|
||||
_testRecyclableListIndexOfV1?.Dispose();
|
||||
_testRecyclableListIndexOfV1 = null;
|
||||
_testRecyclableListIndexOfV2?.Dispose();
|
||||
_testRecyclableListIndexOfV2 = null;
|
||||
_testRecyclableListIndexOfV3?.Dispose();
|
||||
_testRecyclableListIndexOfV3 = null;
|
||||
_testRecyclableListIndexOfV4?.Dispose();
|
||||
_testRecyclableListIndexOfV4 = null;
|
||||
_testPooledList?.Dispose();
|
||||
_testPooledList = null;
|
||||
|
||||
base.Cleanup();
|
||||
}
|
||||
|
||||
protected override Action? GetTestMethod(RecyclableListPocBenchmarkType benchmarkType) => benchmarkType switch
|
||||
{
|
||||
RecyclableListPocBenchmarkType.IndexOfV1 => () => RecyclableList_IndexOfV1(),
|
||||
RecyclableListPocBenchmarkType.IndexOfV2 => () => RecyclableList_IndexOfV2(),
|
||||
RecyclableListPocBenchmarkType.IndexOfV3 => () => RecyclableList_IndexOfV3(),
|
||||
RecyclableListPocBenchmarkType.IndexOfV4 => () => RecyclableList_IndexOfV4(),
|
||||
RecyclableListPocBenchmarkType.IndexOf_PooledList => () => PooledList_IndexOf(),
|
||||
RecyclableListPocBenchmarkType.IndexOf => () => RecyclableList_IndexOf(),
|
||||
RecyclableListPocBenchmarkType.EnsureCapacity_ByPowOf2 => () => RecyclableList_EnsureCapacity_ByPowOf2(),
|
||||
RecyclableListPocBenchmarkType.EnsureCapacityV1_ByPowOf2 => () => RecyclableList_EnsureCapacityV1_ByPowOf2(),
|
||||
RecyclableListPocBenchmarkType.EnsureCapacityV2_ByPowOf2 => () => RecyclableList_EnsureCapacityV2_ByPowOf2(),
|
||||
RecyclableListPocBenchmarkType.EnsureCapacityV3_ByPowOf2 => () => RecyclableList_EnsureCapacityV3_ByPowOf2(),
|
||||
_ => throw CreateUnknownBenchmarkTypeException(benchmarkType),
|
||||
};
|
||||
|
||||
protected override void PrepareData<T>(T benchmarkType)
|
||||
{
|
||||
base.PrepareData(benchmarkType);
|
||||
|
||||
switch (BenchmarkType)
|
||||
{
|
||||
case RecyclableListPocBenchmarkType.IndexOfV1:
|
||||
_testRecyclableListIndexOfV1 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableListPocBenchmarkType.IndexOfV2:
|
||||
_testRecyclableListIndexOfV2 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableListPocBenchmarkType.IndexOfV3:
|
||||
_testRecyclableListIndexOfV3 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableListPocBenchmarkType.IndexOfV4:
|
||||
_testRecyclableListIndexOfV4 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableListPocBenchmarkType.IndexOf_PooledList:
|
||||
_testPooledList = new PooledList<long>(TestObjects, ClearMode.Auto);
|
||||
break;
|
||||
case RecyclableListPocBenchmarkType.IndexOf:
|
||||
_testRecyclableList = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+53
-53
@@ -6,9 +6,9 @@ using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
#region RecyclableList v1
|
||||
#region RecyclableLongList v1
|
||||
|
||||
internal class RecyclableListV1<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListV1<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
|
||||
@@ -352,7 +352,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
return newCapacity;
|
||||
}
|
||||
|
||||
public RecyclableListV1(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListV1(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
{
|
||||
memoryBlocksPool ??= _defaultMemoryBlocksPool;
|
||||
blockArrayPool ??= _defaultBlockArrayPool;
|
||||
@@ -378,7 +378,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
public RecyclableListV1(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListV1(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
{
|
||||
memoryBlocksPool ??= _defaultMemoryBlocksPool;
|
||||
blockArrayPool ??= _defaultBlockArrayPool;
|
||||
@@ -520,7 +520,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListV1<T> items)
|
||||
public void AddRange(RecyclableLongListV1<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -691,9 +691,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.MinPooledArrayLength)
|
||||
{
|
||||
if (source is RecyclableListV1<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongListV1<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -849,7 +849,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListV1()
|
||||
~RecyclableLongListV1()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -873,9 +873,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList v2
|
||||
#region RecyclableLongList v2
|
||||
|
||||
internal class RecyclableListV2<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListV2<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
|
||||
@@ -920,7 +920,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
public int NextItemIndex => _nextItemIndex;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static void CopyItems(RecyclableListV2<T> list, long index)
|
||||
private static void CopyItems(RecyclableLongListV2<T> list, long index)
|
||||
{
|
||||
T[][] memoryBlocks = list._memoryBlocks;
|
||||
int nextItemIndex = list._nextItemIndex;
|
||||
@@ -1111,10 +1111,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <summary>
|
||||
/// Creates a set of new memory buffers, if needed, to allow storing at minimum <paramref name="newCapacity"/> no. of items.
|
||||
/// </summary>
|
||||
/// <param name="list"><see cref="RecyclableListV2{T}"/> that needs to be resized.</param>
|
||||
/// <param name="list"><see cref="RecyclableLongListV2{T}"/> that needs to be resized.</param>
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizeBitShift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableListV2{T}.Resize(RecyclableListV2{T}, int, byte, long)"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableLongListV2{T}.Resize(RecyclableLongListV2{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
@@ -1123,7 +1123,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long Resize(RecyclableListV2<T> list, int minBlockSize, byte minBlockSizeBitShift, long newCapacity)
|
||||
protected static long Resize(RecyclableLongListV2<T> list, int minBlockSize, byte minBlockSizeBitShift, long newCapacity)
|
||||
{
|
||||
ArrayPool<T> blockArrayPool = list._blockArrayPool;
|
||||
int sourceBlockCount = checked((int)(list._capacity >> minBlockSizeBitShift));
|
||||
@@ -1198,14 +1198,14 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
public static long EnsureCapacity(RecyclableListV2<T> list, long requestedCapacity)
|
||||
public static long EnsureCapacity(RecyclableLongListV2<T> list, long requestedCapacity)
|
||||
{
|
||||
long newCapacity = list._capacity > 0
|
||||
? checked((long)BitOperations.RoundUpToPowerOf2((ulong)requestedCapacity))
|
||||
: requestedCapacity;
|
||||
|
||||
int blockSize = list._blockSize;
|
||||
newCapacity = RecyclableListV2<T>.Resize(list, blockSize, list._blockSizePow2Shift, newCapacity);
|
||||
newCapacity = RecyclableLongListV2<T>.Resize(list, blockSize, list._blockSizePow2Shift, newCapacity);
|
||||
if (newCapacity > 0 && blockSize != list._memoryBlocks[0].Length)
|
||||
{
|
||||
blockSize = list._memoryBlocks[0].Length;
|
||||
@@ -1223,7 +1223,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
public RecyclableListV2(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListV2(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
|
||||
@@ -1262,7 +1262,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
public RecyclableListV2(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListV2(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
{
|
||||
memoryBlocksPool ??= _defaultMemoryBlocksPool;
|
||||
_memoryBlocksPool = memoryBlocksPool;
|
||||
@@ -1418,7 +1418,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListV2<T> items)
|
||||
public void AddRange(RecyclableLongListV2<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -1591,9 +1591,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.MinPooledArrayLength)
|
||||
{
|
||||
if (source is RecyclableListV2<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongListV2<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1818,7 +1818,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListV2()
|
||||
~RecyclableLongListV2()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -1842,9 +1842,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList v3
|
||||
#region RecyclableLongList v3
|
||||
|
||||
internal class RecyclableListV3<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListV3<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
|
||||
@@ -1892,7 +1892,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
public int NextItemIndex => _nextItemIndex;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static void CopyItems(RecyclableListV3<T> list, long index)
|
||||
private static void CopyItems(RecyclableLongListV3<T> list, long index)
|
||||
{
|
||||
T[][] memoryBlocks = list._memoryBlocks;
|
||||
int nextItemIndex = list._nextItemIndex;
|
||||
@@ -2083,10 +2083,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <summary>
|
||||
/// Creates a set of new memory buffers, if needed, to allow storing at minimum <paramref name="newCapacity"/> no. of items.
|
||||
/// </summary>
|
||||
/// <param name="list"><see cref="RecyclableList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="list"><see cref="RecyclableLongList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableLongList{T}.Resize(RecyclableLongList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
@@ -2095,7 +2095,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long Resize(RecyclableListV3<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
protected static long Resize(RecyclableLongListV3<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
{
|
||||
ArrayPool<T> blockArrayPool = list._blockArrayPool;
|
||||
int sourceBlockCount = list._reservedBlockCount;
|
||||
@@ -2170,7 +2170,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static void SetupBlockArrayPooling(RecyclableListV3<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
protected static void SetupBlockArrayPooling(RecyclableLongListV3<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
{
|
||||
list._blockSize = blockSize;
|
||||
list._blockSizePow2Shift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
||||
@@ -2187,7 +2187,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long EnsureCapacity(RecyclableListV3<T> list, long requestedCapacity)
|
||||
protected static long EnsureCapacity(RecyclableLongListV3<T> list, long requestedCapacity)
|
||||
{
|
||||
long newCapacity = list._capacity > 0
|
||||
? checked((long)BitOperations.RoundUpToPowerOf2((ulong)requestedCapacity))
|
||||
@@ -2207,7 +2207,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListV3(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListV3(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -2236,7 +2236,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListV3(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListV3(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -2379,7 +2379,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListV3<T> items)
|
||||
public void AddRange(RecyclableLongListV3<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -2552,9 +2552,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.BlockSize)
|
||||
{
|
||||
if (source is RecyclableList<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongList<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2781,7 +2781,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListV3()
|
||||
~RecyclableLongListV3()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -2805,53 +2805,53 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
public partial class RecyclableListPocBenchmarks
|
||||
public partial class RecyclableLongListPocBenchmarks
|
||||
{
|
||||
public void RecyclableList_EnsureCapacityV1_ByPowOf2()
|
||||
public void RecyclableLongList_EnsureCapacityV1_ByPowOf2()
|
||||
{
|
||||
using var list = new RecyclableListV1<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongListV1<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
DoNothing(_ensureCapacityV1Func.Invoke(list, new object[] { TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacityV2_ByPowOf2()
|
||||
public void RecyclableLongList_EnsureCapacityV2_ByPowOf2()
|
||||
{
|
||||
using var list = new RecyclableListV2<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongListV2<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
DoNothing(_ensureCapacityV2Func.Invoke(null, new object[] { list, TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacityV3_ByPowOf2()
|
||||
public void RecyclableLongList_EnsureCapacityV3_ByPowOf2()
|
||||
{
|
||||
using var list = new RecyclableListV3<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongListV3<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
DoNothing(_ensureCapacityV3Func.Invoke(null, new object[] { list, TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacity_ByPowOf2()
|
||||
public void RecyclableLongList_EnsureCapacity_ByPowOf2()
|
||||
{
|
||||
using var list = new RecyclableList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
using var list = new RecyclableLongList<long>(minBlockSize: BlockSize, expectedItemsCount: TestObjectCount);
|
||||
DoNothing(_ensureCapacityNewFunc.Invoke(null, new object[] { list, TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacityV1_ByBlockSize()
|
||||
public void RecyclableLongList_EnsureCapacityV1_ByBlockSize()
|
||||
{
|
||||
using var list = new RecyclableListV1<long>();
|
||||
using var list = new RecyclableLongListV1<long>();
|
||||
DoNothing(_ensureCapacityV1Func.Invoke(list, new object[] { TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacityV2_ByBlockSize()
|
||||
public void RecyclableLongList_EnsureCapacityV2_ByBlockSize()
|
||||
{
|
||||
using var list = new RecyclableListV2<long>();
|
||||
using var list = new RecyclableLongListV2<long>();
|
||||
DoNothing(_ensureCapacityV2Func.Invoke(null, new object[] { list, TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacityV3_ByBlockSize()
|
||||
public void RecyclableLongList_EnsureCapacityV3_ByBlockSize()
|
||||
{
|
||||
using var list = new RecyclableListV3<long>();
|
||||
using var list = new RecyclableLongListV3<long>();
|
||||
DoNothing(_ensureCapacityV3Func.Invoke(null, new object[] { list, TestObjectCount }));
|
||||
}
|
||||
|
||||
public void RecyclableList_EnsureCapacity_ByBlockSize()
|
||||
public void RecyclableLongList_EnsureCapacity_ByBlockSize()
|
||||
{
|
||||
using var list = new RecyclableList<long>();
|
||||
using var list = new RecyclableLongList<long>();
|
||||
DoNothing(_ensureCapacityNewFunc.Invoke(null, new object[] { list, TestObjectCount }));
|
||||
}
|
||||
}
|
||||
+74
-74
@@ -96,9 +96,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList IndexOf v1
|
||||
#region RecyclableLongList IndexOf v1
|
||||
|
||||
internal class RecyclableListIndexOfV1<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListIndexOfV1<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
private const double OptimalParallelSearchStep = 0.329;
|
||||
@@ -153,7 +153,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
public int NextItemIndex => _nextItemIndex;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static void CopyItems(RecyclableListIndexOfV1<T> list, long index)
|
||||
private static void CopyItems(RecyclableLongListIndexOfV1<T> list, long index)
|
||||
{
|
||||
T[][] memoryBlocks = list._memoryBlocks;
|
||||
int nextItemIndex = list._nextItemIndex;
|
||||
@@ -316,7 +316,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
private static long DoLongIndexOfParallel(in RecyclableListIndexOfV1<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
private static long DoLongIndexOfParallel(in RecyclableLongListIndexOfV1<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
{
|
||||
int blockSize = list._blockSize;
|
||||
int blockIndex = itemRange.BlockIndex;
|
||||
@@ -491,10 +491,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <summary>
|
||||
/// Creates a set of new memory buffers, if needed, to allow storing at minimum <paramref name="newCapacity"/> no. of items.
|
||||
/// </summary>
|
||||
/// <param name="list"><see cref="RecyclableList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="list"><see cref="RecyclableLongList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableLongList{T}.Resize(RecyclableLongList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
@@ -507,7 +507,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long Resize(RecyclableListIndexOfV1<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
protected static long Resize(RecyclableLongListIndexOfV1<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
{
|
||||
ArrayPool<T> blockArrayPool = list._blockArrayPool;
|
||||
int sourceBlockCount = list._reservedBlockCount;
|
||||
@@ -594,7 +594,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static void SetupBlockArrayPooling(RecyclableListIndexOfV1<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
protected static void SetupBlockArrayPooling(RecyclableLongListIndexOfV1<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
{
|
||||
list._blockSize = blockSize;
|
||||
list._blockSizePow2BitShift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
||||
@@ -604,7 +604,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long EnsureCapacity(RecyclableListIndexOfV1<T> list, long requestedCapacity)
|
||||
protected static long EnsureCapacity(RecyclableLongListIndexOfV1<T> list, long requestedCapacity)
|
||||
{
|
||||
long newCapacity = list._capacity > 0
|
||||
? checked((long)BitOperations.RoundUpToPowerOf2((ulong)requestedCapacity))
|
||||
@@ -624,7 +624,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV1(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV1(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -653,7 +653,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV1(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV1(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -799,7 +799,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListIndexOfV1<T> items)
|
||||
public void AddRange(RecyclableLongListIndexOfV1<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -975,9 +975,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.BlockSize)
|
||||
{
|
||||
if (source is RecyclableList<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongList<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1219,7 +1219,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListIndexOfV1()
|
||||
~RecyclableLongListIndexOfV1()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -1243,9 +1243,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList IndexOf v2
|
||||
#region RecyclableLongList IndexOf v2
|
||||
|
||||
internal class RecyclableListIndexOfV2<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListIndexOfV2<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
private const double OptimalParallelSearchStep = 0.329;
|
||||
@@ -1300,7 +1300,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
public int NextItemIndex => _nextItemIndex;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static void CopyItems(RecyclableListIndexOfV2<T> list, long index)
|
||||
private static void CopyItems(RecyclableLongListIndexOfV2<T> list, long index)
|
||||
{
|
||||
T[][] memoryBlocks = list._memoryBlocks;
|
||||
int nextItemIndex = list._nextItemIndex;
|
||||
@@ -1463,7 +1463,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
private static long DoLongIndexOfParallel(in RecyclableListIndexOfV2<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
private static long DoLongIndexOfParallel(in RecyclableLongListIndexOfV2<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
{
|
||||
int blockSize = list._blockSize;
|
||||
int blockIndex = itemRange.BlockIndex;
|
||||
@@ -1636,10 +1636,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <summary>
|
||||
/// Creates a set of new memory buffers, if needed, to allow storing at minimum <paramref name="newCapacity"/> no. of items.
|
||||
/// </summary>
|
||||
/// <param name="list"><see cref="RecyclableList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="list"><see cref="RecyclableLongList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableLongList{T}.Resize(RecyclableLongList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
@@ -1652,7 +1652,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long Resize(RecyclableListIndexOfV2<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
protected static long Resize(RecyclableLongListIndexOfV2<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
{
|
||||
ArrayPool<T> blockArrayPool = list._blockArrayPool;
|
||||
int sourceBlockCount = list._reservedBlockCount;
|
||||
@@ -1739,7 +1739,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static void SetupBlockArrayPooling(RecyclableListIndexOfV2<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
protected static void SetupBlockArrayPooling(RecyclableLongListIndexOfV2<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
{
|
||||
list._blockSize = blockSize;
|
||||
list._blockSizePow2BitShift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
||||
@@ -1749,7 +1749,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long EnsureCapacity(RecyclableListIndexOfV2<T> list, long requestedCapacity)
|
||||
protected static long EnsureCapacity(RecyclableLongListIndexOfV2<T> list, long requestedCapacity)
|
||||
{
|
||||
long newCapacity = list._capacity > 0
|
||||
? checked((long)BitOperations.RoundUpToPowerOf2((ulong)requestedCapacity))
|
||||
@@ -1769,7 +1769,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV2(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV2(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -1798,7 +1798,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV2(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV2(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -1944,7 +1944,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListIndexOfV2<T> items)
|
||||
public void AddRange(RecyclableLongListIndexOfV2<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -2120,9 +2120,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.BlockSize)
|
||||
{
|
||||
if (source is RecyclableListIndexOfV2<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongListIndexOfV2<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -2364,7 +2364,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListIndexOfV2()
|
||||
~RecyclableLongListIndexOfV2()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -2388,9 +2388,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList IndexOf v3
|
||||
#region RecyclableLongList IndexOf v3
|
||||
|
||||
internal class RecyclableListIndexOfV3<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListIndexOfV3<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const long ItemNotFoundIndexLong = -1L;
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
@@ -2446,7 +2446,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
public int NextItemIndex => _nextItemIndex;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static void CopyItems(RecyclableListIndexOfV3<T> list, long index)
|
||||
private static void CopyItems(RecyclableLongListIndexOfV3<T> list, long index)
|
||||
{
|
||||
T[][] memoryBlocks = list._memoryBlocks;
|
||||
int nextItemIndex = list._nextItemIndex;
|
||||
@@ -2608,7 +2608,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
private static long DoLongIndexOfParallel(in RecyclableListIndexOfV3<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
private static long DoLongIndexOfParallel(in RecyclableLongListIndexOfV3<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
{
|
||||
int blockSize = list._blockSize;
|
||||
int blockIndex = itemRange.BlockIndex;
|
||||
@@ -2753,10 +2753,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <summary>
|
||||
/// Creates a set of new memory buffers, if needed, to allow storing at minimum <paramref name="newCapacity"/> no. of items.
|
||||
/// </summary>
|
||||
/// <param name="list"><see cref="RecyclableList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="list"><see cref="RecyclableLongList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableLongList{T}.Resize(RecyclableLongList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
@@ -2769,7 +2769,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long Resize(RecyclableListIndexOfV3<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
protected static long Resize(RecyclableLongListIndexOfV3<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
{
|
||||
ArrayPool<T> blockArrayPool = list._blockArrayPool;
|
||||
int sourceBlockCount = list._reservedBlockCount;
|
||||
@@ -2856,7 +2856,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static void SetupBlockArrayPooling(RecyclableListIndexOfV3<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
protected static void SetupBlockArrayPooling(RecyclableLongListIndexOfV3<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
{
|
||||
list._blockSize = blockSize;
|
||||
list._blockSizePow2BitShift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
||||
@@ -2866,7 +2866,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long EnsureCapacity(RecyclableListIndexOfV3<T> list, long requestedCapacity)
|
||||
protected static long EnsureCapacity(RecyclableLongListIndexOfV3<T> list, long requestedCapacity)
|
||||
{
|
||||
long newCapacity = list._capacity > 0
|
||||
? checked((long)BitOperations.RoundUpToPowerOf2((ulong)requestedCapacity))
|
||||
@@ -2886,7 +2886,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV3(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV3(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -2915,7 +2915,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV3(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV3(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -3061,7 +3061,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListIndexOfV3<T> items)
|
||||
public void AddRange(RecyclableLongListIndexOfV3<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -3237,9 +3237,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.BlockSize)
|
||||
{
|
||||
if (source is RecyclableList<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongList<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3478,7 +3478,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListIndexOfV3()
|
||||
~RecyclableLongListIndexOfV3()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -3502,15 +3502,15 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
#region RecyclableList IndexOf v4
|
||||
#region RecyclableLongList IndexOf v4
|
||||
|
||||
internal static class RecyclableListIndexOfV4Extensions
|
||||
internal static class RecyclableLongListIndexOfV4Extensions
|
||||
{
|
||||
private const long ItemNotFoundIndexLong = -1L;
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.AggressiveInlining)]
|
||||
public static long DoLongIndexOfParallel<T>(this RecyclableListIndexOfV4<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
public static long DoLongIndexOfParallel<T>(this RecyclableLongListIndexOfV4<T> list, in ItemRangeV1 itemRange, in T itemToFind, in ManualResetEventSlimmer itemFoundSignal)
|
||||
{
|
||||
int blockSize = list._blockSize;
|
||||
int blockIndex = itemRange.BlockIndex;
|
||||
@@ -3583,7 +3583,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
internal class RecyclableListIndexOfV4<T> : IDisposable, IList<T>
|
||||
internal class RecyclableLongListIndexOfV4<T> : IDisposable, IList<T>
|
||||
{
|
||||
private const long ItemNotFoundIndexLong = -1L;
|
||||
private const int ItemNotFoundIndex = -1;
|
||||
@@ -3639,7 +3639,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
public int NextItemIndex => _nextItemIndex;
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
private static void CopyItems(RecyclableListIndexOfV4<T> list, long index)
|
||||
private static void CopyItems(RecyclableLongListIndexOfV4<T> list, long index)
|
||||
{
|
||||
T[][] memoryBlocks = list._memoryBlocks;
|
||||
int nextItemIndex = list._nextItemIndex;
|
||||
@@ -3817,7 +3817,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
return ItemNotFoundIndexLong;
|
||||
}
|
||||
|
||||
private static bool ScheduleIndexOfTasks(ParallelSynchronizationContextV4 context, RecyclableListIndexOfV4<T> list, T itemToFind, ItemRangeV1 itemRange)
|
||||
private static bool ScheduleIndexOfTasks(ParallelSynchronizationContextV4 context, RecyclableLongListIndexOfV4<T> list, T itemToFind, ItemRangeV1 itemRange)
|
||||
{
|
||||
_ = context.AllDoneSignal.AddParticipant();
|
||||
_ = Task.Factory.StartNew(() =>
|
||||
@@ -3845,7 +3845,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization | MethodImplOptions.NoInlining)]
|
||||
public static void Iterate(in ParallelSynchronizationContextV4 context, RecyclableListIndexOfV4<T> list, in T itemToFind, Func<ParallelSynchronizationContextV4, RecyclableListIndexOfV4<T>, T, ItemRangeV1, bool> action)
|
||||
public static void Iterate(in ParallelSynchronizationContextV4 context, RecyclableLongListIndexOfV4<T> list, in T itemToFind, Func<ParallelSynchronizationContextV4, RecyclableLongListIndexOfV4<T>, T, ItemRangeV1, bool> action)
|
||||
{
|
||||
int itemIndex = 0;
|
||||
ItemRangeV1 itemRange;
|
||||
@@ -3907,10 +3907,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// <summary>
|
||||
/// Creates a set of new memory buffers, if needed, to allow storing at minimum <paramref name="newCapacity"/> no. of items.
|
||||
/// </summary>
|
||||
/// <param name="list"><see cref="RecyclableList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="list"><see cref="RecyclableLongList{T}"/> that needs to be resized.</param>
|
||||
/// <param name="minBlockSize">Minimal requested block size. It MUST be rounded to the power of 2, see remarks.</param>
|
||||
/// <param name="minBlockSizePow2Shift">Pre-calculated bit shifting value for left & right shift operations against<paramref name="minBlockSize"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableList{T}.Resize(RecyclableList{T}, int, byte, long)"/>.</param>
|
||||
/// <param name="newCapacity">The minimum no. of items <paramref name="list"/> MUST be able to store after <see cref="RecyclableLongList{T}.Resize(RecyclableLongList{T}, int, byte, long)"/>.</param>
|
||||
/// <remarks><para>
|
||||
/// For performance reasons, <paramref name="minBlockSize"/> MUST a power of 2. This simplifies a lot block & item
|
||||
/// index calculations, i.e. makes them logical operations on bits.
|
||||
@@ -3923,7 +3923,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
/// </remarks>
|
||||
/// <returns>The maximum no. of items <paramref name="list"/> can store.</returns>
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long Resize(RecyclableListIndexOfV4<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
protected static long Resize(RecyclableLongListIndexOfV4<T> list, int minBlockSize, byte minBlockSizePow2Shift, long newCapacity)
|
||||
{
|
||||
ArrayPool<T> blockArrayPool = list._blockArrayPool;
|
||||
int sourceBlockCount = list._reservedBlockCount;
|
||||
@@ -4010,7 +4010,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static void SetupBlockArrayPooling(RecyclableListIndexOfV4<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
protected static void SetupBlockArrayPooling(RecyclableLongListIndexOfV4<T> list, int blockSize, ArrayPool<T>? blockArrayPool = null)
|
||||
{
|
||||
list._blockSize = blockSize;
|
||||
list._blockSizePow2BitShift = (byte)(31 - BitOperations.LeadingZeroCount((uint)blockSize));
|
||||
@@ -4020,7 +4020,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.AggressiveOptimization)]
|
||||
protected static long EnsureCapacity(RecyclableListIndexOfV4<T> list, long requestedCapacity)
|
||||
protected static long EnsureCapacity(RecyclableLongListIndexOfV4<T> list, long requestedCapacity)
|
||||
{
|
||||
long newCapacity = list._capacity > 0
|
||||
? checked((long)BitOperations.RoundUpToPowerOf2((ulong)requestedCapacity))
|
||||
@@ -4040,7 +4040,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV4(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV4(int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -4069,7 +4069,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
#pragma warning disable CS8618 // It's set by SetupBlockArrayPooling
|
||||
public RecyclableListIndexOfV4(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
public RecyclableLongListIndexOfV4(IEnumerable<T> source, int minBlockSize = RecyclableDefaults.BlockSize, long? expectedItemsCount = default, ArrayPool<T[]>? memoryBlocksPool = default, ArrayPool<T>? blockArrayPool = default)
|
||||
#pragma warning restore CS8618
|
||||
{
|
||||
_memoryBlocksPool = memoryBlocksPool ?? _defaultMemoryBlocksPool;
|
||||
@@ -4215,7 +4215,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_nextItemBlockIndex = targetBlockIndex;
|
||||
}
|
||||
|
||||
public void AddRange(RecyclableListIndexOfV4<T> items)
|
||||
public void AddRange(RecyclableLongListIndexOfV4<T> items)
|
||||
{
|
||||
if (items.LongCount == 0)
|
||||
{
|
||||
@@ -4391,9 +4391,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
public void AddRange(IEnumerable<T> source, int growByCount = RecyclableDefaults.BlockSize)
|
||||
{
|
||||
if (source is RecyclableList<T> sourceRecyclableList)
|
||||
if (source is RecyclableLongList<T> sourceRecyclableLongList)
|
||||
{
|
||||
AddRange(sourceRecyclableList);
|
||||
AddRange(sourceRecyclableLongList);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4632,7 +4632,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
IEnumerator IEnumerable.GetEnumerator() => _memoryBlocks.Enumerate(_blockSize, LongCount).GetEnumerator();
|
||||
|
||||
~RecyclableListIndexOfV4()
|
||||
~RecyclableLongListIndexOfV4()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in 'Dispose(bool disposing)' method
|
||||
Dispose();
|
||||
@@ -4656,12 +4656,12 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
|
||||
#endregion
|
||||
|
||||
public partial class RecyclableListPocBenchmarks
|
||||
public partial class RecyclableLongListPocBenchmarks
|
||||
{
|
||||
public void RecyclableList_IndexOfV1()
|
||||
public void RecyclableLongList_IndexOfV1()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableListIndexOfV1;
|
||||
var list = TestObjectsAsRecyclableLongListIndexOfV1;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -4680,10 +4680,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOfV2()
|
||||
public void RecyclableLongList_IndexOfV2()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableListIndexOfV2;
|
||||
var list = TestObjectsAsRecyclableLongListIndexOfV2;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -4691,10 +4691,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOfV3()
|
||||
public void RecyclableLongList_IndexOfV3()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableListIndexOfV3;
|
||||
var list = TestObjectsAsRecyclableLongListIndexOfV3;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -4702,10 +4702,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOfV4()
|
||||
public void RecyclableLongList_IndexOfV4()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableListIndexOfV4;
|
||||
var list = TestObjectsAsRecyclableLongListIndexOfV4;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -4713,10 +4713,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
}
|
||||
|
||||
public void RecyclableList_IndexOf()
|
||||
public void RecyclableLongList_IndexOf()
|
||||
{
|
||||
var data = TestObjects;
|
||||
var list = TestObjectsAsRecyclableList;
|
||||
var list = TestObjectsAsRecyclableLongList;
|
||||
var dataCount = TestObjectCount;
|
||||
for (var i = 0; i < dataCount; i++)
|
||||
{
|
||||
@@ -0,0 +1,157 @@
|
||||
using System.Reflection;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Recyclable.Collections.Benchmarks.Core;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
public enum RecyclableLongListPocBenchmarkType
|
||||
{
|
||||
IndexOfV1,
|
||||
IndexOfV2,
|
||||
IndexOfV3,
|
||||
IndexOfV4,
|
||||
IndexOf_PooledList,
|
||||
IndexOf,
|
||||
EnsureCapacity_ByPowOf2,
|
||||
EnsureCapacityV1_ByPowOf2,
|
||||
EnsureCapacityV2_ByPowOf2,
|
||||
EnsureCapacityV3_ByPowOf2,
|
||||
}
|
||||
|
||||
[MemoryDiagnoser]
|
||||
public partial class RecyclableLongListPocBenchmarks : PocBenchmarkBase<RecyclableLongListPocBenchmarkType>
|
||||
{
|
||||
[Params(RecyclableLongListPocBenchmarkType.IndexOf)]
|
||||
public override RecyclableLongListPocBenchmarkType BenchmarkType { get => base.BenchmarkType; set => base.BenchmarkType = value; }
|
||||
|
||||
// [Params(BenchmarkType.Array, BenchmarkType.List, BenchmarkType.RecyclableArrayList, BenchmarkType.RecyclableLongList)]
|
||||
[Params(RecyclableLongListPocBenchmarkType.IndexOf_PooledList)]
|
||||
public override RecyclableLongListPocBenchmarkType BaselineBenchmarkType { get => base.BaselineBenchmarkType; set => base.BaselineBenchmarkType = value; }
|
||||
|
||||
private long[]? _testArray;
|
||||
public long[] TestObjects => _testArray ?? throw new NullReferenceException("Something is wrong and test objects are null");
|
||||
|
||||
public RecyclableLongList<long> TestObjectsAsRecyclableLongList => _testRecyclableLongList ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableLongList<long>)} is null");
|
||||
private RecyclableLongListIndexOfV1<long>? _testRecyclableLongListIndexOfV1;
|
||||
internal RecyclableLongListIndexOfV1<long> TestObjectsAsRecyclableLongListIndexOfV1 => _testRecyclableLongListIndexOfV1 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableLongListIndexOfV1<long>)} is null");
|
||||
private RecyclableLongListIndexOfV2<long>? _testRecyclableLongListIndexOfV2;
|
||||
private RecyclableLongList<long>? _testRecyclableLongList;
|
||||
internal RecyclableLongListIndexOfV2<long> TestObjectsAsRecyclableLongListIndexOfV2 => _testRecyclableLongListIndexOfV2 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableLongListIndexOfV2<long>)} is null");
|
||||
private RecyclableLongListIndexOfV3<long>? _testRecyclableLongListIndexOfV3;
|
||||
internal RecyclableLongListIndexOfV3<long> TestObjectsAsRecyclableLongListIndexOfV3 => _testRecyclableLongListIndexOfV3 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableLongListIndexOfV3<long>)} is null");
|
||||
private RecyclableLongListIndexOfV4<long>? _testRecyclableLongListIndexOfV4;
|
||||
internal RecyclableLongListIndexOfV4<long> TestObjectsAsRecyclableLongListIndexOfV4 => _testRecyclableLongListIndexOfV4 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableLongListIndexOfV4<long>)} is null");
|
||||
private PooledList<long>? _testPooledList;
|
||||
internal PooledList<long> TestPooledList => _testPooledList ?? throw new NullReferenceException($"Something is wrong and {nameof(PooledList<long>)} is null");
|
||||
|
||||
private static readonly MethodInfo _ensureCapacityNewFunc;
|
||||
private static readonly MethodInfo _ensureCapacityV1Func;
|
||||
private static readonly MethodInfo _ensureCapacityV2Func;
|
||||
private static readonly MethodInfo _ensureCapacityV3Func;
|
||||
|
||||
static RecyclableLongListPocBenchmarks()
|
||||
{
|
||||
_ensureCapacityNewFunc = typeof(RecyclableLongList<long>).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.NonPublic)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableLongList<long>)}");
|
||||
|
||||
_ensureCapacityV1Func = typeof(RecyclableLongListV1<long>).GetMethod("EnsureCapacity", BindingFlags.Instance | BindingFlags.NonPublic)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableLongListV1<long>)}");
|
||||
|
||||
_ensureCapacityV2Func = typeof(RecyclableLongListV2<long>).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.Public)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableLongListV2<long>)}");
|
||||
|
||||
_ensureCapacityV3Func = typeof(RecyclableLongListV3<long>).GetMethod("EnsureCapacity", BindingFlags.Static | BindingFlags.NonPublic)
|
||||
?? throw new NullReferenceException($"Method EnsureCapacity not found in class {nameof(RecyclableLongListV3<long>)}");
|
||||
}
|
||||
|
||||
public static void Run()
|
||||
{
|
||||
var benchmark = new RecyclableLongListPocBenchmarks();
|
||||
benchmark.Setup();
|
||||
// benchmark.RecyclableLongList_EnsureCapacity_ByPowOf2();
|
||||
// benchmark.RecyclableLongList_EnsureCapacityV1_ByPowOf2();
|
||||
// benchmark.RecyclableLongList_EnsureCapacityV2_ByPowOf2();
|
||||
// benchmark.RecyclableLongList_EnsureCapacityV3_ByPowOf2();
|
||||
// benchmark.RecyclableLongList_EnsureCapacity_ByBlockSize();
|
||||
// benchmark.RecyclableLongList_EnsureCapacityV1_ByBlockSize();
|
||||
// benchmark.RecyclableLongList_EnsureCapacityV2_ByBlockSize();
|
||||
// benchmark.RecyclableLongList_EnsureCapacityV3_ByBlockSize();
|
||||
benchmark.RecyclableLongList_IndexOf();
|
||||
benchmark.RecyclableLongList_IndexOfV1();
|
||||
benchmark.RecyclableLongList_IndexOfV2();
|
||||
benchmark.RecyclableLongList_IndexOfV3();
|
||||
benchmark.RecyclableLongList_IndexOfV4();
|
||||
benchmark.Cleanup();
|
||||
}
|
||||
|
||||
public override void Setup()
|
||||
{
|
||||
Console.WriteLine("******* SETTING UP EXPECTED RESULTS DATA *******");
|
||||
_testArray = DataGenerator.EnumerateTestObjects(TestObjectCount);
|
||||
|
||||
base.Setup();
|
||||
}
|
||||
|
||||
public override void Cleanup()
|
||||
{
|
||||
_testArray = null;
|
||||
_testRecyclableLongList?.Dispose();
|
||||
_testRecyclableLongList = null;
|
||||
_testRecyclableLongListIndexOfV1?.Dispose();
|
||||
_testRecyclableLongListIndexOfV1 = null;
|
||||
_testRecyclableLongListIndexOfV2?.Dispose();
|
||||
_testRecyclableLongListIndexOfV2 = null;
|
||||
_testRecyclableLongListIndexOfV3?.Dispose();
|
||||
_testRecyclableLongListIndexOfV3 = null;
|
||||
_testRecyclableLongListIndexOfV4?.Dispose();
|
||||
_testRecyclableLongListIndexOfV4 = null;
|
||||
_testPooledList?.Dispose();
|
||||
_testPooledList = null;
|
||||
|
||||
base.Cleanup();
|
||||
}
|
||||
|
||||
protected override Action? GetTestMethod(RecyclableLongListPocBenchmarkType benchmarkType) => benchmarkType switch
|
||||
{
|
||||
RecyclableLongListPocBenchmarkType.IndexOfV1 => () => RecyclableLongList_IndexOfV1(),
|
||||
RecyclableLongListPocBenchmarkType.IndexOfV2 => () => RecyclableLongList_IndexOfV2(),
|
||||
RecyclableLongListPocBenchmarkType.IndexOfV3 => () => RecyclableLongList_IndexOfV3(),
|
||||
RecyclableLongListPocBenchmarkType.IndexOfV4 => () => RecyclableLongList_IndexOfV4(),
|
||||
RecyclableLongListPocBenchmarkType.IndexOf_PooledList => () => PooledList_IndexOf(),
|
||||
RecyclableLongListPocBenchmarkType.IndexOf => () => RecyclableLongList_IndexOf(),
|
||||
RecyclableLongListPocBenchmarkType.EnsureCapacity_ByPowOf2 => () => RecyclableLongList_EnsureCapacity_ByPowOf2(),
|
||||
RecyclableLongListPocBenchmarkType.EnsureCapacityV1_ByPowOf2 => () => RecyclableLongList_EnsureCapacityV1_ByPowOf2(),
|
||||
RecyclableLongListPocBenchmarkType.EnsureCapacityV2_ByPowOf2 => () => RecyclableLongList_EnsureCapacityV2_ByPowOf2(),
|
||||
RecyclableLongListPocBenchmarkType.EnsureCapacityV3_ByPowOf2 => () => RecyclableLongList_EnsureCapacityV3_ByPowOf2(),
|
||||
_ => throw CreateUnknownBenchmarkTypeException(benchmarkType),
|
||||
};
|
||||
|
||||
protected override void PrepareData<T>(T benchmarkType)
|
||||
{
|
||||
base.PrepareData(benchmarkType);
|
||||
|
||||
switch (BenchmarkType)
|
||||
{
|
||||
case RecyclableLongListPocBenchmarkType.IndexOfV1:
|
||||
_testRecyclableLongListIndexOfV1 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableLongListPocBenchmarkType.IndexOfV2:
|
||||
_testRecyclableLongListIndexOfV2 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableLongListPocBenchmarkType.IndexOfV3:
|
||||
_testRecyclableLongListIndexOfV3 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableLongListPocBenchmarkType.IndexOfV4:
|
||||
_testRecyclableLongListIndexOfV4 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
case RecyclableLongListPocBenchmarkType.IndexOf_PooledList:
|
||||
_testPooledList = new PooledList<long>(TestObjects, ClearMode.Auto);
|
||||
break;
|
||||
case RecyclableLongListPocBenchmarkType.IndexOf:
|
||||
_testRecyclableLongList = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
BenchmarkDotNet=v0.13.3, OS=ubuntu 20.04
|
||||
Intel Xeon Platinum 8272CL CPU 2.60GHz, 1 CPU, 4 logical and 2 physical cores
|
||||
.NET SDK=7.0.203
|
||||
[Host] : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
|
||||
DefaultJob : .NET 7.0.5 (7.0.523.17405), X64 RyuJIT AVX2
|
||||
|
||||
|
||||
| Method | Mean | Error | StdDev | Ratio | RatioSD |
|
||||
|------------------------- |--------:|---------:|---------:|------:|--------:|
|
||||
| RecyclableLongList_IndexOfV1 | 2.274 s | 0.0447 s | 0.0894 s | 1.00 | 0.04 |
|
||||
| RecyclableLongList_IndexOfV2 | 2.302 s | 0.0456 s | 0.0750 s | 1.00 | 0.00 |
|
||||
| RecyclableLongList_IndexOf | 2.234 s | 0.0446 s | 0.0681 s | 0.97 | 0.05 |
|
||||
|
||||
// * Hints *
|
||||
Outliers
|
||||
RecyclableLongListPocBenchmarks.RecyclableLongList_IndexOfV2: Default -> 2 outliers were removed (2.54 s, 2.56 s)
|
||||
RecyclableLongListPocBenchmarks.RecyclableLongList_IndexOf: Default -> 1 outlier was detected (2.06 s)
|
||||
|
||||
// * Legends *
|
||||
Mean : Arithmetic mean of all measurements
|
||||
Error : Half of 99.9% confidence interval
|
||||
StdDev : Standard deviation of all measurements
|
||||
Ratio : Mean of the ratio distribution ([Current]/[Baseline])
|
||||
RatioSD : Standard deviation of the ratio distribution ([Current]/[Baseline])
|
||||
1 s : 1 Second (1 sec)
|
||||
|
||||
@@ -78,7 +78,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
//[Params(329_000, 512_000, 750_000, 1_000_000, 3_290_000)]
|
||||
//public int Step { get; set; } = 329_000; // This was the fastest so far
|
||||
|
||||
private RecyclableList<long>? _testData;
|
||||
private RecyclableLongList<long>? _testData;
|
||||
|
||||
public object? ItemToFind { get; set; }
|
||||
|
||||
@@ -123,7 +123,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveOptimization)]
|
||||
private static long DoLongIndexOfParallel(RecyclableList<long> list, in long itemToFind, ItemRangeV2 searchInfo, ManualResetEventSlim itemFoundSignal)
|
||||
private static long DoLongIndexOfParallel(RecyclableLongList<long> list, in long itemToFind, ItemRangeV2 searchInfo, ManualResetEventSlim itemFoundSignal)
|
||||
{
|
||||
int index;
|
||||
int blockSize = list.BlockSize;
|
||||
@@ -300,7 +300,7 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
{
|
||||
base.PrepareData(benchmarkType);
|
||||
|
||||
_testData ??= Enumerable.Range(1, TestObjectCount).Cast<long>().ToRecyclableList(BlockSize);
|
||||
_testData ??= Enumerable.Range(1, TestObjectCount).Cast<long>().ToRecyclableLongList(BlockSize);
|
||||
ItemToFind ??= _testData.Last();
|
||||
}
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ internal class Program
|
||||
|
||||
//foreach (var _ in Enumerable.Range(1, 1000))
|
||||
//{
|
||||
//benchmark.RecyclableList_Remove_FirstItems();
|
||||
//benchmark.RecyclableList_RemoveAt_LastItems();
|
||||
//benchmark.RecyclableLongList_Remove_FirstItems();
|
||||
//benchmark.RecyclableLongList_RemoveAt_LastItems();
|
||||
//benchmark.List_RemoveAt_LastItems();
|
||||
//}
|
||||
|
||||
@@ -40,7 +40,7 @@ internal class Program
|
||||
_ = BenchmarkRunner.Run<BoolOrComparePocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<DelegateVsComparerPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<ModuloPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<RecyclableListPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<RecyclableLongListPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<RefVsInstanceMemberPocBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<WhenParallelSearchBenchmarks>(BenchmarkConfig);
|
||||
_ = BenchmarkRunner.Run<RoundBenchmarks>(BenchmarkConfig);
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace Recyclable.Collections.Benchmarks
|
||||
List,
|
||||
PooledList,
|
||||
RecyclableArrayList,
|
||||
RecyclableList,
|
||||
RecyclableLongList,
|
||||
}
|
||||
|
||||
[MemoryDiagnoser]
|
||||
@@ -28,8 +28,8 @@ namespace Recyclable.Collections.Benchmarks
|
||||
public PooledList<long> TestObjectsAsPooledList => _testObjectsAsPooledList ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
|
||||
protected RecyclableArrayList<long>? _testObjectsAsRecyclableArrayList;
|
||||
protected RecyclableArrayList<long> TestObjectsAsRecyclableArrayList => _testObjectsAsRecyclableArrayList ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
|
||||
protected RecyclableList<long>? _testObjectsAsRecyclableList;
|
||||
protected RecyclableList<long> TestObjectsAsRecyclableList => _testObjectsAsRecyclableList ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
|
||||
protected RecyclableLongList<long>? _testObjectsAsRecyclableLongList;
|
||||
protected RecyclableLongList<long> TestObjectsAsRecyclableLongList => _testObjectsAsRecyclableLongList ?? throw new NullReferenceException("Something is wrong and the field is not initialized");
|
||||
protected IEnumerable<long> TestObjectsAsIEnumerable
|
||||
{
|
||||
get
|
||||
@@ -68,8 +68,8 @@ namespace Recyclable.Collections.Benchmarks
|
||||
_testObjectsAsRecyclableArrayList ??= new(TestObjects, initialCapacity: TestObjectCount);
|
||||
break;
|
||||
|
||||
case RecyclableCollectionsBenchmarkSource.RecyclableList:
|
||||
_testObjectsAsRecyclableList ??= new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
case RecyclableCollectionsBenchmarkSource.RecyclableLongList:
|
||||
_testObjectsAsRecyclableLongList ??= new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -94,8 +94,8 @@ namespace Recyclable.Collections.Benchmarks
|
||||
_testObjectsAsPooledList = default;
|
||||
_testObjectsAsRecyclableArrayList?.Dispose();
|
||||
_testObjectsAsRecyclableArrayList = default;
|
||||
_testObjectsAsRecyclableList?.Dispose();
|
||||
_testObjectsAsRecyclableList = default;
|
||||
_testObjectsAsRecyclableLongList?.Dispose();
|
||||
_testObjectsAsRecyclableLongList = default;
|
||||
base.Cleanup();
|
||||
}
|
||||
}
|
||||
@@ -123,11 +123,11 @@ namespace Recyclable.Collections.Benchmarks
|
||||
// }
|
||||
|
||||
// [Benchmark(Baseline = true)]
|
||||
// public void RecyclableList()
|
||||
// public void RecyclableLongList()
|
||||
// {
|
||||
// var data = TestObjects;
|
||||
// long dataCount = TestObjectCount;
|
||||
// using var list = new RecyclableList<object>(BlockSize, totalItemsCount: dataCount);
|
||||
// using var list = new RecyclableLongList<object>(BlockSize, totalItemsCount: dataCount);
|
||||
// for (long i = 0; i < dataCount; i++)
|
||||
// {
|
||||
// list.Add(data[i]);
|
||||
|
||||
@@ -8,115 +8,115 @@
|
||||
| List_Create_WithCapacity | 2,377.6 us | 43.03 us | 40.25 us | 1.93 | 0.03 | 54.6875 | 54.6875 | 54.6875 | 8000451 B | 137,938.81 |
|
||||
| PooledList_Create_WithCapacity | 1,229.4 us | 10.70 us | 9.48 us | 1.00 | 0.00 | - | - | - | 58 B | 1.00 |
|
||||
| RecyclableArrayList_Create_WithCapacity | 1,233.9 us | 3.93 us | 3.68 us | 1.00 | 0.01 | - | - | - | 41 B | 0.71 |
|
||||
| RecyclableList_Create_WithCapacity | 786.5 us | 2.32 us | 1.94 us | 0.64 | 0.01 | - | - | - | 425 B | 7.33 |
|
||||
| RecyclableLongList_Create_WithCapacity | 786.5 us | 2.32 us | 1.94 us | 0.64 | 0.01 | - | - | - | 425 B | 7.33 |
|
||||
|
||||
| List_Create | 3.5523 ns | 0.0181 ns | 0.0141 ns | 3.5476 ns | 0.000 | 0.00 | 0.0153 | - | - | 32 B | 0.000 |
|
||||
| PooledList_Create | 6.9236 ns | 0.0110 ns | 0.0098 ns | 6.9222 ns | 0.000 | 0.00 | 0.0268 | - | - | 56 B | 0.000 |
|
||||
| RecyclableArrayList_Create | 4.6451 ns | 0.0063 ns | 0.0053 ns | 4.6457 ns | 0.000 | 0.00 | 0.0191 | - | - | 40 B | 0.000 |
|
||||
| RecyclableList_Create | 212.8164 ns | 11.9841 ns | 35.3355 ns | 213.2258 ns | 0.000 | 0.00 | 0.0381 | 0.0379 | - | 80 B | 0.000 |
|
||||
| RecyclableLongList_Create | 212.8164 ns | 11.9841 ns | 35.3355 ns | 213.2258 ns | 0.000 | 0.00 | 0.0381 | 0.0379 | - | 80 B | 0.000 |
|
||||
|
||||
Array_GetItem | 239.7 us | 0.36 us | 0.32 us | 0.66 | 0.00 | - | NA |
|
||||
List_GetItem | 363.5 us | 0.67 us | 0.56 us | 1.00 | 0.00 | - | NA |
|
||||
PooledList_GetItem | 365.3 us | 0.90 us | 0.75 us | 1.00 | 0.00 | - | NA |
|
||||
RecyclableArrayList_GetItem | 239.2 us | 0.07 us | 0.06 us | 0.65 | 0.00 | - | NA |
|
||||
RecyclableList_GetItem | 538.0 us | 1.01 us | 0.89 us | 1.47 | 0.00 | 1 B | NA |
|
||||
RecyclableList_GetItem_AsSpan | 673.5 us | 4.85 us | 4.30 us | 1.84 | 0.01 | 1 B | NA |
|
||||
RecyclableList_GetItem_AsArray | 239.4 us | 0.22 us | 0.20 us | 0.66 | 0.00 | - | NA |
|
||||
RecyclableList_GetItem_AsForEach | 5,514.6 us | 27.28 us | 22.78 us | 15.10 | 0.06 | 109 B | NA |
|
||||
RecyclableList_GetItem_AsWhile | 459.3 us | 0.38 us | 0.34 us | 1.26 | 0.00 | - | NA |
|
||||
RecyclableLongList_GetItem | 538.0 us | 1.01 us | 0.89 us | 1.47 | 0.00 | 1 B | NA |
|
||||
RecyclableLongList_GetItem_AsSpan | 673.5 us | 4.85 us | 4.30 us | 1.84 | 0.01 | 1 B | NA |
|
||||
RecyclableLongList_GetItem_AsArray | 239.4 us | 0.22 us | 0.20 us | 0.66 | 0.00 | - | NA |
|
||||
RecyclableLongList_GetItem_AsForEach | 5,514.6 us | 27.28 us | 22.78 us | 15.10 | 0.06 | 109 B | NA |
|
||||
RecyclableLongList_GetItem_AsWhile | 459.3 us | 0.38 us | 0.34 us | 1.26 | 0.00 | - | NA |
|
||||
|
||||
| Array_SetItem | 2,576,086.8389 ns | 13,880.4584 ns | 11,590.8114 ns | 2,576,978.1250 ns | 2.194 | 0.01 | - | - | - | 2 B | 0.000 |
|
||||
| List_SetItem | 3,361,745.7734 ns | 98,390.1277 ns | 290,105.5114 ns | 3,505,120.8984 ns | 2.771 | 0.29 | - | - | - | 2 B | 0.000 |
|
||||
| PooledList_SetItem | 2,676,757.7524 ns | 1,228.8178 ns | 1,026.1185 ns | 2,676,991.4062 ns | 2.280 | 0.01 | - | - | - | 2 B | 0.000 |
|
||||
| RecyclableArrayList_SetItem | 2,547,059.6540 ns | 9,002.9953 ns | 7,980.9208 ns | 2,542,056.8359 ns | 2.170 | 0.01 | - | - | - | 2 B | 0.000 |
|
||||
| RecyclableList_SetItem | 2,326,771.9866 ns | 3,186.0942 ns | 2,824.3895 ns | 2,326,636.7188 ns | 1.981 | 0.01 | - | - | - | 2 B | 0.000 |
|
||||
| RecyclableLongList_SetItem | 2,326,771.9866 ns | 3,186.0942 ns | 2,824.3895 ns | 2,326,636.7188 ns | 1.981 | 0.01 | - | - | - | 2 B | 0.000 |
|
||||
|
||||
| Method | Mean | Error | StdDev | Ratio | RatioSD | Gen0 | Gen1 | Gen2 | Allocated | Alloc Ratio |
|
||||
|------------------------------------------------------------ |----------:|----------:|----------:|------:|--------:|---------:|--------:|--------:|-----------:|------------:|
|
||||
| List_Add | 11.002 ms | 0.2189 ms | 0.2996 ms | 1.36 | 0.04 | 140.6250 | 93.7500 | 93.7500 | 16778117 B | 236,311.51 |
|
||||
| PooledList_Add | 8.117 ms | 0.0115 ms | 0.0102 ms | 1.00 | 0.00 | - | - | - | 71 B | 1.00 |
|
||||
| RecyclableArrayList_Add | 8.771 ms | 0.0169 ms | 0.0141 ms | 1.08 | 0.00 | - | - | - | 1233 B | 17.37 |
|
||||
| RecyclableList_Add | 6.024 ms | 0.1101 ms | 0.1030 ms | 0.74 | 0.01 | - | - | - | 3317 B | 46.72 |
|
||||
| RecyclableLongList_Add | 6.024 ms | 0.1101 ms | 0.1030 ms | 0.74 | 0.01 | - | - | - | 3317 B | 46.72 |
|
||||
|
||||
| List_Add_WithCapacity | 3,724,682.0668 ns | 88,719.4866 ns | 260,198.8962 ns | 3,717,873.0469 ns | 3.326 | 0.09 | 50.7813 | 50.7813 | 50.7813 | 4000368 B | 1.000 |
|
||||
| PooledList_Add_WithCapacity | 2,575,618.8337 ns | 5,277.9410 ns | 4,678.7572 ns | 2,575,805.2734 ns | 2.194 | 0.01 | - | - | - | 60 B | 0.000 |
|
||||
| RecyclableArrayList_Add_WithCapacity | 2,785,606.2500 ns | 4,595.4354 ns | 4,073.7338 ns | 2,785,292.7734 ns | 2.372 | 0.01 | - | - | - | 42 B | 0.000 |
|
||||
| RecyclableList_Add_WithCapacity | 2,878,685.9701 ns | 44,974.7609 ns | 35,113.3350 ns | 2,873,102.9297 ns | 2.453 | 0.03 | - | - | - | 170 B | 0.000 |
|
||||
| RecyclableLongList_Add_WithCapacity | 2,878,685.9701 ns | 44,974.7609 ns | 35,113.3350 ns | 2,873,102.9297 ns | 2.453 | 0.03 | - | - | - | 170 B | 0.000 |
|
||||
|
||||
| List_AddRangeWhenSourceIsArray | 1,966,607.1581 ns | 39,075.4380 ns | 100,165.2861 ns | 1,958,457.4219 ns | 1.721 | 0.07 | 42.9688 | 42.9688 | 42.9688 | 4000364 B | 1.000 |
|
||||
| PooledList_AddRangeWhenSourceIsArray | 972,973.4049 ns | 12,365.6121 ns | 11,566.8012 ns | 974,744.8242 ns | 0.829 | 0.01 | - | - | - | 57 B | 0.000 |
|
||||
| RecyclableArrayList_AddRangeWhenSourceIsArray | 1,098,651.7578 ns | 3,202.7829 ns | 2,995.8851 ns | 1,097,979.4922 ns | 0.936 | 0.00 | - | - | - | 41 B | 0.000 |
|
||||
| RecyclableList_AddRangeWhenSourceIsArray | 1,023,799.0234 ns | 2,772.1984 ns | 2,457.4816 ns | 1,023,618.7500 ns | 0.872 | 0.00 | - | - | - | 169 B | 0.000 |
|
||||
| RecyclableLongList_AddRangeWhenSourceIsArray | 1,023,799.0234 ns | 2,772.1984 ns | 2,457.4816 ns | 1,023,618.7500 ns | 0.872 | 0.00 | - | - | - | 169 B | 0.000 |
|
||||
|
||||
| List_AddRangeWhenSourceIsList | 1,954,805.9462 ns | 37,631.3829 ns | 71,597.6170 ns | 1,947,531.6406 ns | 1.656 | 0.06 | 42.9688 | 42.9688 | 42.9688 | 4000363 B | 1.000 |
|
||||
| PooledList_AddRangeWhenSourceIsList | 963,657.7116 ns | 5,594.8195 ns | 5,233.3976 ns | 965,055.4199 ns | 0.820 | 0.01 | - | - | - | 57 B | 0.000 |
|
||||
| RecyclableArrayList_AddRangeWhenSourceIsList | 1,114,697.8385 ns | 4,015.8164 ns | 3,756.3971 ns | 1,115,863.6719 ns | 0.950 | 0.00 | - | - | - | 41 B | 0.000 |
|
||||
| RecyclableList_AddRangeWhenSourceIsList | 1,008,424.0374 ns | 2,179.7502 ns | 1,932.2918 ns | 1,008,779.8828 ns | 0.859 | 0.00 | - | - | - | 169 B | 0.000 |
|
||||
| RecyclableLongList_AddRangeWhenSourceIsList | 1,008,424.0374 ns | 2,179.7502 ns | 1,932.2918 ns | 1,008,779.8828 ns | 0.859 | 0.00 | - | - | - | 169 B | 0.000 |
|
||||
|
||||
| List_AddRangeWhenSourceIsIList | 2,045,453.8895 ns | 40,653.4327 ns | 98,956.0738 ns | 2,040,041.7969 ns | 1.734 | 0.12 | 42.9688 | 42.9688 | 42.9688 | 4000366 B | 1.000 |
|
||||
| PooledList_AddRangeWhenSourceIsIList | 977,402.4790 ns | 4,165.1933 ns | 3,478.1251 ns | 978,420.3125 ns | 0.832 | 0.00 | - | - | - | 58 B | 0.000 |
|
||||
| RecyclableArrayList_AddRangeWhenSourceIsIList | 1,109,563.8477 ns | 4,480.2733 ns | 4,190.8505 ns | 1,108,281.9336 ns | 0.945 | 0.00 | - | - | - | 41 B | 0.000 |
|
||||
| RecyclableList_AddRangeWhenSourceIsIList | 2,632,797.0052 ns | 3,899.2563 ns | 3,044.2828 ns | 2,632,267.1875 ns | 2.243 | 0.01 | - | - | - | 170 B | 0.000 |
|
||||
| RecyclableLongList_AddRangeWhenSourceIsIList | 2,632,797.0052 ns | 3,899.2563 ns | 3,044.2828 ns | 2,632,267.1875 ns | 2.243 | 0.01 | - | - | - | 170 B | 0.000 |
|
||||
|
||||
| PooledList_AddRangeWhenSourceIsIEnumerable | 28,102,425.4630 ns | 556,294.1092 ns | 779,846.6478 ns | 28,009,543.7500 ns | 24.007 | 0.74 | 2187.5000 | 1375.0000 | 218.7500 | 12000526 B | 3.000 |
|
||||
| List_AddRangeWhenSourceIsIEnumerable | 47,884,030.8442 ns | 955,391.3313 ns | 1,370,193.6989 ns | 48,152,172.7273 ns | 40.578 | 1.04 | 2272.7273 | 1363.6364 | 363.6364 | 20389288 B | 5.097 |
|
||||
| RecyclableArrayList_AddRangeWhenSourceIsIEnumerable | 27,102,237.2533 ns | 535,598.7947 ns | 595,316.6412 ns | 27,248,382.8125 ns | 23.009 | 0.61 | 2250.0000 | 1406.2500 | 250.0000 | 12000305 B | 3.000 |
|
||||
| RecyclableList_AddRangeWhenSourceIsIEnumerable | 27,206,882.1023 ns | 517,997.7196 ns | 636,147.7188 ns | 27,262,153.1250 ns | 23.049 | 0.64 | 2218.7500 | 1468.7500 | 250.0000 | 12000361 B | 3.000 |
|
||||
| RecyclableLongList_AddRangeWhenSourceIsIEnumerable | 27,206,882.1023 ns | 517,997.7196 ns | 636,147.7188 ns | 27,262,153.1250 ns | 23.049 | 0.64 | 2218.7500 | 1468.7500 | 250.0000 | 12000361 B | 3.000 |
|
||||
|
||||
| PooledList_AddRangeWhenSourceIsPooledList | 958,132.3033 ns | 4,444.5508 ns | 3,939.9785 ns | 957,355.9570 ns | 0.816 | 0.00 | - | - | - | 57 B | 0.000 |
|
||||
| RecyclableArrayList_AddRangeWhenSourceIsRecyclableArrayList | 1,068,135.4492 ns | 15,036.9473 ns | 12,556.5320 ns | 1,063,337.2070 ns | 0.910 | 0.01 | - | - | - | 41 B | 0.000 |
|
||||
| RecyclableList_AddRangeWhenSourceIsRecyclableArrayList | 1,057,253.7249 ns | 2,697.5224 ns | 2,391.2834 ns | 1,057,475.9766 ns | 0.901 | 0.00 | - | - | - | 169 B | 0.000 |
|
||||
| RecyclableLongList_AddRangeWhenSourceIsRecyclableArrayList | 1,057,253.7249 ns | 2,697.5224 ns | 2,391.2834 ns | 1,057,475.9766 ns | 0.901 | 0.00 | - | - | - | 169 B | 0.000 |
|
||||
|
||||
| List_AddRange_WithCapacity | 2,022,247.3039 ns | 44,489.4467 ns | 129,071.9520 ns | 2,030,418.9453 ns | 1.767 | 0.06 | 39.0625 | 39.0625 | 39.0625 | 4000318 B | 1.000 |
|
||||
| PooledList_AddRange_WithCapacity | 965,635.9570 ns | 11,740.2154 ns | 10,981.8048 ns | 968,593.2617 ns | 0.822 | 0.01 | - | - | - | 57 B | 0.000 |
|
||||
| RecyclableArrayList_AddRange_WithCapacity | 1,044,438.5517 ns | 3,047.5353 ns | 2,544.8300 ns | 1,045,038.8672 ns | 0.890 | 0.00 | - | - | - | 41 B | 0.000 |
|
||||
| RecyclableList_AddRange_WithCapacity | 1,028,953.5156 ns | 17,735.8499 ns | 14,810.2379 ns | 1,022,104.4922 ns | 0.876 | 0.01 | - | - | - | 169 B | 0.000 |
|
||||
| RecyclableLongList_AddRange_WithCapacity | 1,028,953.5156 ns | 17,735.8499 ns | 14,810.2379 ns | 1,022,104.4922 ns | 0.876 | 0.01 | - | - | - | 169 B | 0.000 |
|
||||
|
||||
| Array_Count | 0.0087 ns | 0.0110 ns | 0.0103 ns | 0.0024 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| List_Count | 1.2190 ns | 0.0046 ns | 0.0040 ns | 1.2173 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| PooledList_Count | 0.0037 ns | 0.0015 ns | 0.0012 ns | 0.0040 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| RecyclableArrayList_Count | 1.2096 ns | 0.0009 ns | 0.0008 ns | 1.2092 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| RecyclableList_Count | 0.0103 ns | 0.0008 ns | 0.0007 ns | 0.0102 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| RecyclableLongList_Count | 0.0103 ns | 0.0008 ns | 0.0007 ns | 0.0102 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
|
||||
| Array_LongCount | 0.0021 ns | 0.0005 ns | 0.0004 ns | 0.0022 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| RecyclableList_LongCount | 0.0030 ns | 0.0004 ns | 0.0003 ns | 0.0031 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
| RecyclableLongList_LongCount | 0.0030 ns | 0.0004 ns | 0.0003 ns | 0.0031 ns | 0.000 | 0.00 | - | - | - | - | 0.000 |
|
||||
|
||||
| List_Contains_FirstItems | 1,855,720,661.5385 ns | 16,632,292.4881 ns | 13,888,717.5079 ns | 1,850,307,400.0000 ns | 1,580.480 | 10.24 | - | - | - | 600 B | 0.000 |
|
||||
| PooledList_Contains_FirstItems | 1,854,542,814.2857 ns | 3,151,361.3032 ns | 2,793,599.7119 ns | 1,855,147,650.0000 ns | 1,579.345 | 5.84 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableList_Contains_FirstItems | 1,842,715,553.8462 ns | 5,837,438.3043 ns | 4,874,525.3630 ns | 1,840,917,300.0000 ns | 1,569.420 | 6.23 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableLongList_Contains_FirstItems | 1,842,715,553.8462 ns | 5,837,438.3043 ns | 4,874,525.3630 ns | 1,840,917,300.0000 ns | 1,569.420 | 6.23 | - | - | - | 600 B | 0.000 |
|
||||
|
||||
| List_Contains_LastItems | 56,934,350,853.3333 ns | 257,718,254.2389 ns | 241,069,814.9149 ns | 56,884,611,800.0000 ns | 48,516.143 | 270.39 | - | - | - | 600 B | 0.000 |
|
||||
| PooledList_Contains_LastItems | 57,262,565,633.3333 ns | 295,685,051.7358 ns | 276,583,980.8497 ns | 57,246,796,900.0000 ns | 48,801.131 | 237.64 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableList_Contains_LastItems | 57,019,747,564.2857 ns | 264,241,719.1753 ns | 234,243,401.3552 ns | 57,059,345,900.0000 ns | 48,552.402 | 223.09 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableLongList_Contains_LastItems | 57,019,747,564.2857 ns | 264,241,719.1753 ns | 234,243,401.3552 ns | 57,059,345,900.0000 ns | 48,552.402 | 223.09 | - | - | - | 600 B | 0.000 |
|
||||
|
||||
| Array_IndexOf_FirstItems | 1,874,810,260.0000 ns | 25,774,115.5271 ns | 24,109,123.6555 ns | 1,867,388,700.0000 ns | 1,597.521 | 22.54 | - | - | - | 600 B | 0.000 |
|
||||
| List_IndexOf_FirstItems | 1,864,704,725.0000 ns | 10,982,470.8154 ns | 8,574,390.8164 ns | 1,866,253,200.0000 ns | 1,588.702 | 10.94 | - | - | - | 600 B | 0.000 |
|
||||
| PooledList_IndexOf_FirstItems | 1,840,856,800.0000 ns | 4,046,589.8784 ns | 3,159,311.2037 ns | 1,839,944,050.0000 ns | 1,568.374 | 6.17 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableArrayList_IndexOf_FirstItems | 1,832,934,950.0000 ns | 1,729,308.0131 ns | 1,350,129.9476 ns | 1,832,475,300.0000 ns | 1,561.625 | 5.52 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableList_IndexOf_FirstItems | 1,844,986,792.3077 ns | 3,209,050.1952 ns | 2,679,702.2516 ns | 1,843,943,600.0000 ns | 1,571.359 | 6.49 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableList_LongIndexOf_FirstItems | 1,878,933,500.0000 ns | 17,118,131.6171 ns | 16,012,310.9355 ns | 1,870,009,600.0000 ns | 1,601.616 | 14.82 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableLongList_IndexOf_FirstItems | 1,844,986,792.3077 ns | 3,209,050.1952 ns | 2,679,702.2516 ns | 1,843,943,600.0000 ns | 1,571.359 | 6.49 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableLongList_LongIndexOf_FirstItems | 1,878,933,500.0000 ns | 17,118,131.6171 ns | 16,012,310.9355 ns | 1,870,009,600.0000 ns | 1,601.616 | 14.82 | - | - | - | 600 B | 0.000 |
|
||||
|
||||
| List_IndexOf_LastItems | 57,303,575,140.0000 ns | 297,612,744.3548 ns | 278,387,145.7216 ns | 57,391,576,000.0000 ns | 48,792.865 | 303.56 | - | - | - | 600 B | 0.000 |
|
||||
| PooledList_IndexOf_LastItems | 57,032,399,106.6667 ns | 281,241,865.3817 ns | 263,073,815.3730 ns | 56,895,992,200.0000 ns | 48,566.622 | 322.88 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableList_IndexOf_LastItems | 57,308,279,713.3333 ns | 272,718,905.6589 ns | 255,101,433.5602 ns | 57,297,645,400.0000 ns | 48,767.562 | 239.96 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableList_LongIndexOf_LastItems | 57,198,323,460.0000 ns | 282,971,632.5816 ns | 264,691,840.6850 ns | 57,198,418,300.0000 ns | 48,669.107 | 304.11 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableLongList_IndexOf_LastItems | 57,308,279,713.3333 ns | 272,718,905.6589 ns | 255,101,433.5602 ns | 57,297,645,400.0000 ns | 48,767.562 | 239.96 | - | - | - | 600 B | 0.000 |
|
||||
| RecyclableLongList_LongIndexOf_LastItems | 57,198,323,460.0000 ns | 282,971,632.5816 ns | 264,691,840.6850 ns | 57,198,418,300.0000 ns | 48,669.107 | 304.11 | - | - | - | 600 B | 0.000 |
|
||||
|
||||
| List_Remove_FirstItems | 5,023,030,012.5000 ns | 82,615,052.4052 ns | 107,422,903.9562 ns | 5,000,417,000.0000 ns | 4,295.171 | 116.37 | - | - | - | 4000656 B | 1.000 |
|
||||
| PooledList_Remove_FirstItems | 4,750,601,721.4286 ns | 17,989,258.8487 ns | 15,947,009.4038 ns | 4,747,622,550.0000 ns | 4,043.997 | 21.26 | - | - | - | 992 B | 0.000 |
|
||||
| RecyclableArrayList_Remove_FirstItems | 4,950,634,900.0000 ns | 33,761,094.2570 ns | 29,928,330.6849 ns | 4,936,519,050.0000 ns | 4,218.075 | 23.90 | - | - | - | 640 B | 0.000 |
|
||||
| RecyclableList_Remove_FirstItems | 5,020,383,250.0000 ns | 100,209,734.5497 ns | 115,401,679.3276 ns | 5,029,163,750.0000 ns | 4,306.772 | 86.95 | - | - | - | 952 B | 0.000 |
|
||||
| RecyclableLongList_Remove_FirstItems | 5,020,383,250.0000 ns | 100,209,734.5497 ns | 115,401,679.3276 ns | 5,029,163,750.0000 ns | 4,306.772 | 86.95 | - | - | - | 952 B | 0.000 |
|
||||
|
||||
| List_Remove_LastItems | 56,593,869,333.3333 ns | 258,693,958.6041 ns | 241,982,489.3835 ns | 56,513,091,800.0000 ns | 48,189.227 | 272.02 | - | - | - | 4000656 B | 1.000 |
|
||||
| PooledList_Remove_LastItems | 56,465,443,542.8571 ns | 99,443,506.1766 ns | 88,154,078.0245 ns | 56,458,364,050.0000 ns | 48,092.866 | 216.09 | - | - | - | 992 B | 0.000 |
|
||||
| RecyclableArrayList_Remove_LastItems | 57,432,405,146.6667 ns | 264,062,625.8226 ns | 247,004,344.0307 ns | 57,409,508,000.0000 ns | 48,952.707 | 234.83 | - | - | - | 640 B | 0.000 |
|
||||
| RecyclableList_Remove_LastItems | 57,077,678,728.5714 ns | 210,992,675.8689 ns | 187,039,511.4398 ns | 57,038,290,150.0000 ns | 48,614.503 | 242.79 | - | - | - | 952 B | 0.000 |
|
||||
| RecyclableLongList_Remove_LastItems | 57,077,678,728.5714 ns | 210,992,675.8689 ns | 187,039,511.4398 ns | 57,038,290,150.0000 ns | 48,614.503 | 242.79 | - | - | - | 952 B | 0.000 |
|
||||
|
||||
| List_RemoveAt_FirstItems | 4,517,669,893.3333 ns | 77,360,576.7460 ns | 72,363,131.4861 ns | 4,546,302,700.0000 ns | 3,850.590 | 62.34 | - | - | - | 4000656 B | 1.000 |
|
||||
| PooledList_RemoveAt_FirstItems | 4,439,417,700.0000 ns | 40,915,112.8948 ns | 38,272,021.9874 ns | 4,418,366,400.0000 ns | 3,779.751 | 38.92 | - | - | - | 992 B | 0.000 |
|
||||
| RecyclableArrayList_RemoveAt_FirstItems | 4,558,102,892.8571 ns | 25,076,973.8515 ns | 22,230,084.1404 ns | 4,559,174,800.0000 ns | 3,882.107 | 16.61 | - | - | - | 640 B | 0.000 |
|
||||
| RecyclableList_RemoveAt_FirstItems | 4,617,033,766.6667 ns | 85,061,197.3076 ns | 79,566,296.7373 ns | 4,632,994,800.0000 ns | 3,928.768 | 72.17 | - | - | - | 952 B | 0.000 |
|
||||
| RecyclableLongList_RemoveAt_FirstItems | 4,617,033,766.6667 ns | 85,061,197.3076 ns | 79,566,296.7373 ns | 4,632,994,800.0000 ns | 3,928.768 | 72.17 | - | - | - | 952 B | 0.000 |
|
||||
|
||||
| List_RemoveAt_LastItems | 2,005,211.3281 ns | 40,078.0351 ns | 84,538.1787 ns | 2,010,579.1016 ns | 1.725 | 0.08 | 42.9688 | 42.9688 | 42.9688 | 4000306 B | 1.000 |
|
||||
| PooledList_RemoveAt_LastItems | 1,047,436.1654 ns | 5,655.2027 ns | 5,289.8801 ns | 1,044,690.9180 ns | 0.892 | 0.01 | - | - | - | 58 B | 0.000 |
|
||||
| RecyclableArrayList_RemoveAt_LastItems | 1,256,380.8969 ns | 9,142.3285 ns | 7,634.2584 ns | 1,254,354.9805 ns | 1.070 | 0.01 | - | - | - | 41 B | 0.000 |
|
||||
| RecyclableList_RemoveAt_LastItems | 1,621,193.5826 ns | 20,030.6198 ns | 17,756.6227 ns | 1,620,789.8438 ns | 1.379 | 0.02 | - | - | - | 353 B | 0.000 |
|
||||
| RecyclableLongList_RemoveAt_LastItems | 1,621,193.5826 ns | 20,030.6198 ns | 17,756.6227 ns | 1,620,789.8438 ns | 1.379 | 0.02 | - | - | - | 353 B | 0.000 |
|
||||
Reference in new issue
Block a user