Skip to content

Instantly share code, notes, and snippets.

@dariogriffo
Created December 15, 2023 12:06
Show Gist options
  • Save dariogriffo/9cf83d64211c05223f12b36d48545319 to your computer and use it in GitHub Desktop.
Save dariogriffo/9cf83d64211c05223f12b36d48545319 to your computer and use it in GitHub Desktop.
using BenchmarkDotNet.Attributes;
[MemoryDiagnoser]
public class ABC
{
private string[] data;
[Params(1000, 10000, 100000)]
public int N;
[GlobalSetup]
public void Setup()
{
data = new string[N];
for (var i = 0; i < N/2; ++i)
{
data[i] = new Random(42).NextDouble().ToString();
}
for (var i = N/2+1; i < N; ++i)
{
data[i] = Guid.NewGuid().ToString("B").Split('-')[0];
}
Random.Shared.Shuffle(data);
}
[Benchmark]
public void Me() => data.MeNonNumericIndexes<double>();
[Benchmark]
public void KarenPayne() => data.KarenPayneNonNumericIndexes<double>();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment