Skip to content

Commit

Permalink
Improve performance of Span.Clear for referential T
Browse files Browse the repository at this point in the history
Commit migrated from dotnet/corefx@4e3a6d0
  • Loading branch information
GrabYourPitchforks authored and joshfree committed Mar 6, 2018
1 parent d02b3a1 commit 10a4d23
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,45 @@ public void Int(int size)
}
}
}

[Benchmark]
[InlineData(0)]
[InlineData(1)]
[InlineData(2)]
[InlineData(3)]
[InlineData(4)]
[InlineData(5)]
[InlineData(6)]
[InlineData(7)]
[InlineData(8)]
[InlineData(9)]
[InlineData(10)]
[InlineData(11)]
[InlineData(12)]
[InlineData(13)]
[InlineData(14)]
[InlineData(15)]
[InlineData(16)]
[InlineData(32)]
[InlineData(64)]
[InlineData(100)]
[InlineData(1000)]
[InlineData(10000)]
[InlineData(100000)]
public void References(int size)
{
var a = new object[size];
var span = new Span<object>(a);
foreach (BenchmarkIteration iteration in Benchmark.Iterations)
{
using (iteration.StartMeasurement())
{
for (int i = 0; i < 10000; i++)
{
span.Clear();
}
}
}
}
}
}

0 comments on commit 10a4d23

Please sign in to comment.