diff --git a/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs b/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs index 8557482041320..167603d9b2862 100644 --- a/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs +++ b/src/libraries/System.Memory/tests/Performance/Perf.Span.Clear.cs @@ -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(a); + foreach (BenchmarkIteration iteration in Benchmark.Iterations) + { + using (iteration.StartMeasurement()) + { + for (int i = 0; i < 10000; i++) + { + span.Clear(); + } + } + } + } } }