RecyclableArrayList[int index] set performance improvement. Add marked for aggresive inlining.
This commit is contained in:
1 parent
63773415e7
commit
bf2d966f28
5 files changed
+8
-6
No files matched your search
@@ -3,8 +3,8 @@ using Recyclable.Collections.Benchmarks;
|
|||||||
|
|
||||||
//BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "-f*" });
|
//BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "-f*" });
|
||||||
|
|
||||||
//BenchmarkRunner.Run<RecyclableCollectionsBenchmarks>();
|
BenchmarkRunner.Run<RecyclableCollectionsBenchmarks>();
|
||||||
BenchmarkRunner.Run<RefVsInstanceMemberBenchmarks>();
|
//BenchmarkRunner.Run<RefVsInstanceMemberBenchmarks>();
|
||||||
|
|
||||||
//var benchmark = new RecyclableCollectionsBenchmarks();
|
//var benchmark = new RecyclableCollectionsBenchmarks();
|
||||||
//benchmark.RecyclableArrayList_AddRange_WithCapacity();
|
//benchmark.RecyclableArrayList_AddRange_WithCapacity();
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
{
|
{
|
||||||
private readonly object[] _testArray;
|
private readonly object[] _testArray;
|
||||||
|
|
||||||
[Benchmark(Baseline = false)]
|
//[Benchmark(Baseline = false)]
|
||||||
public void Array_Create_WithCapacity()
|
public void Array_Create_WithCapacity()
|
||||||
{
|
{
|
||||||
var data = new object[TestObjectCount];
|
var data = new object[TestObjectCount];
|
||||||
|
|||||||
+3
-2
@@ -12,12 +12,15 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
_testRecyclableList = new(TestObjects, TestObjectCount);
|
_testRecyclableList = new(TestObjects, TestObjectCount);
|
||||||
_testArray = TestObjects.ToArray();
|
_testArray = TestObjects.ToArray();
|
||||||
_testList = new(TestObjects);
|
_testList = new(TestObjects);
|
||||||
|
_ = TestObjectsAsList;
|
||||||
|
_ = TestObjectsAsRecyclableArrayList;
|
||||||
}
|
}
|
||||||
|
|
||||||
~RecyclableCollectionsBenchmarks()
|
~RecyclableCollectionsBenchmarks()
|
||||||
{
|
{
|
||||||
_testRecyclableArrayList?.Dispose();
|
_testRecyclableArrayList?.Dispose();
|
||||||
_testRecyclableList?.Dispose();
|
_testRecyclableList?.Dispose();
|
||||||
|
TestObjectsAsRecyclableArrayList?.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
//[Benchmark]
|
//[Benchmark]
|
||||||
@@ -123,8 +126,6 @@ namespace Recyclable.Collections.Benchmarks
|
|||||||
{
|
{
|
||||||
data[i] = TestObjects[i];
|
data[i] = TestObjects[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
data.Count = dataCount;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
|
|||||||
@@ -127,7 +127,7 @@ namespace Recyclable.Collections
|
|||||||
public T this[int index]
|
public T this[int index]
|
||||||
{
|
{
|
||||||
get => _memory[index];
|
get => _memory[index];
|
||||||
set => _memory[index] = value;
|
set => new Span<T>(_memory)[index] = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int _capacity;
|
protected int _capacity;
|
||||||
@@ -153,6 +153,7 @@ namespace Recyclable.Collections
|
|||||||
|
|
||||||
public bool IsReadOnly { get; } = false;
|
public bool IsReadOnly { get; } = false;
|
||||||
|
|
||||||
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public void Add(T item)
|
public void Add(T item)
|
||||||
{
|
{
|
||||||
int requestedCapacity = _count + 1;
|
int requestedCapacity = _count + 1;
|
||||||
|
|||||||
Binary file not shown.
|
After Width: | Height: | Size: 84 KiB |
Reference in new issue
Block a user