RecyclableList.IndexOf parallel performance improvements.
This commit is contained in:
1 parent
99600d4854
commit
3db10d7602
21 files changed
+4282
-511
No files matched your search
@@ -1,4 +1,5 @@
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Recyclable.Collections.Pools;
|
||||
using System.Buffers;
|
||||
using System.Collections;
|
||||
using System.Numerics;
|
||||
|
||||
File diff suppressed because it is too large.
Load diff
@@ -1,6 +1,7 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.CompilerServices;
|
||||
using BenchmarkDotNet.Attributes;
|
||||
using Collections.Pooled;
|
||||
using Recyclable.Collections.Benchmarks.Core;
|
||||
|
||||
namespace Recyclable.Collections.Benchmarks.POC
|
||||
@@ -10,9 +11,17 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
private long[]? _testArray;
|
||||
public long[] TestObjects => _testArray ?? throw new NullReferenceException("Something is wrong and test objects are null");
|
||||
private RecyclableList<long>? _testRecyclableList;
|
||||
public RecyclableList<long> TestObjectsAsRecyclableList => _testRecyclableList ?? throw new NullReferenceException("Something is wrong and RecyclableList is 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 RecyclableListIndexOfV1 is null");
|
||||
internal RecyclableListIndexOfV1<long> TestObjectsAsRecyclableListIndexOfV1 => _testRecyclableListIndexOfV1 ?? throw new NullReferenceException($"Something is wrong and {nameof(RecyclableListIndexOfV1<long>)} is null");
|
||||
private RecyclableListIndexOfV2<long>? _testRecyclableListIndexOfV2;
|
||||
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;
|
||||
@@ -47,6 +56,9 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
benchmark.RecyclableList_EnsureCapacityV3_ByBlockSize();
|
||||
benchmark.RecyclableList_IndexOf();
|
||||
benchmark.RecyclableList_IndexOfV1();
|
||||
benchmark.RecyclableList_IndexOfV2();
|
||||
benchmark.RecyclableList_IndexOfV3();
|
||||
benchmark.RecyclableList_IndexOfV4();
|
||||
}
|
||||
|
||||
[GlobalSetup]
|
||||
@@ -55,6 +67,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_testArray = DataGenerator.EnumerateTestObjects(TestObjectCount);
|
||||
_testRecyclableList = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
_testRecyclableListIndexOfV1 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
_testRecyclableListIndexOfV2 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
_testRecyclableListIndexOfV3 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
_testRecyclableListIndexOfV4 = new(TestObjects, BlockSize, expectedItemsCount: TestObjectCount);
|
||||
_testPooledList = new PooledList<long>(TestObjects, ClearMode.Auto);
|
||||
|
||||
// Warm up memory pools for fair comparison with 1st run
|
||||
RecyclableList_EnsureCapacity_ByPowOf2();
|
||||
@@ -63,6 +79,10 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
RecyclableList_EnsureCapacityV3_ByPowOf2();
|
||||
RecyclableList_IndexOf();
|
||||
RecyclableList_IndexOfV1();
|
||||
RecyclableList_IndexOfV2();
|
||||
RecyclableList_IndexOfV3();
|
||||
RecyclableList_IndexOfV4();
|
||||
PooledList_IndexOf();
|
||||
}
|
||||
|
||||
[GlobalCleanup]
|
||||
@@ -73,6 +93,15 @@ namespace Recyclable.Collections.Benchmarks.POC
|
||||
_testRecyclableList = null;
|
||||
_testRecyclableListIndexOfV1?.Dispose();
|
||||
_testRecyclableListIndexOfV1 = null;
|
||||
_testRecyclableListIndexOfV2?.Dispose();
|
||||
_testRecyclableListIndexOfV2 = null;
|
||||
_testRecyclableListIndexOfV3?.Dispose();
|
||||
_testRecyclableListIndexOfV3 = null;
|
||||
_testRecyclableListIndexOfV4?.Dispose();
|
||||
_testRecyclableListIndexOfV4 = null;
|
||||
_testPooledList?.Dispose();
|
||||
_testPooledList = null;
|
||||
GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced, true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user