diff --git a/Recyclable.Collections.Benchmarks/Program.cs b/Recyclable.Collections.Benchmarks/Program.cs index c9eba31..52450ac 100644 --- a/Recyclable.Collections.Benchmarks/Program.cs +++ b/Recyclable.Collections.Benchmarks/Program.cs @@ -3,8 +3,8 @@ using Recyclable.Collections.Benchmarks; //BenchmarkSwitcher.FromAssembly(typeof(Program).Assembly).Run(new[] { "-f*" }); -//BenchmarkRunner.Run(); -BenchmarkRunner.Run(); +BenchmarkRunner.Run(); +//BenchmarkRunner.Run(); //var benchmark = new RecyclableCollectionsBenchmarks(); //benchmark.RecyclableArrayList_AddRange_WithCapacity(); diff --git a/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.Array.cs b/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.Array.cs index d82524b..c138fb9 100644 --- a/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.Array.cs +++ b/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.Array.cs @@ -7,7 +7,7 @@ namespace Recyclable.Collections.Benchmarks { private readonly object[] _testArray; - [Benchmark(Baseline = false)] + //[Benchmark(Baseline = false)] public void Array_Create_WithCapacity() { var data = new object[TestObjectCount]; diff --git a/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.RecyclableArrayList.cs b/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.RecyclableArrayList.cs index 08d3f16..a85ee9b 100644 --- a/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.RecyclableArrayList.cs +++ b/Recyclable.Collections.Benchmarks/RecyclableCollectionsBenchmarks.RecyclableArrayList.cs @@ -12,12 +12,15 @@ namespace Recyclable.Collections.Benchmarks _testRecyclableList = new(TestObjects, TestObjectCount); _testArray = TestObjects.ToArray(); _testList = new(TestObjects); + _ = TestObjectsAsList; + _ = TestObjectsAsRecyclableArrayList; } ~RecyclableCollectionsBenchmarks() { _testRecyclableArrayList?.Dispose(); _testRecyclableList?.Dispose(); + TestObjectsAsRecyclableArrayList?.Dispose(); } //[Benchmark] @@ -123,8 +126,6 @@ namespace Recyclable.Collections.Benchmarks { data[i] = TestObjects[i]; } - - data.Count = dataCount; } [Benchmark] diff --git a/Recyclable.Collections/RecyclableArrayList.cs b/Recyclable.Collections/RecyclableArrayList.cs index 2542b79..d5af696 100644 --- a/Recyclable.Collections/RecyclableArrayList.cs +++ b/Recyclable.Collections/RecyclableArrayList.cs @@ -127,7 +127,7 @@ namespace Recyclable.Collections public T this[int index] { get => _memory[index]; - set => _memory[index] = value; + set => new Span(_memory)[index] = value; } protected int _capacity; @@ -153,6 +153,7 @@ namespace Recyclable.Collections public bool IsReadOnly { get; } = false; + [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Add(T item) { int requestedCapacity = _count + 1; diff --git a/Recyclable.Collections/RecyclableArrayList_AllInOneBenchmarks.png b/Recyclable.Collections/RecyclableArrayList_AllInOneBenchmarks.png new file mode 100644 index 0000000..2056af0 Binary files /dev/null and b/Recyclable.Collections/RecyclableArrayList_AllInOneBenchmarks.png differ