chore: minor adjustments to benchmarks
This commit is contained in:
parent
eb0b81cf59
commit
b78c7adf39
1 changed files with 8 additions and 8 deletions
|
@ -11,10 +11,10 @@ namespace Benchmarks;
|
|||
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
|
||||
public class DataCacheBenchmark
|
||||
{
|
||||
private ConcurrentDictionary<int, int> _concurrentDictionary;
|
||||
private Dictionary<int, int> _dictionary;
|
||||
private HashSet<int> _hashSet;
|
||||
private ImmutableHashSet<int> _immutableHashSet;
|
||||
private ConcurrentDictionary<int, int> _concurrentDictionary = null!;
|
||||
private Dictionary<int, int> _dictionary = null!;
|
||||
private HashSet<int> _hashSet = null!;
|
||||
private ImmutableHashSet<int> _immutableHashSet = null!;
|
||||
[Params(1000, 100000, 1000000)] public int N;
|
||||
|
||||
[GlobalSetup]
|
||||
|
@ -63,24 +63,24 @@ public class DataCacheBenchmark
|
|||
[Benchmark]
|
||||
public void ImmutableHashSetLookup()
|
||||
{
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _immutableHashSet.Contains(i));
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _immutableHashSet.Contains(i); });
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void HashSetLookup()
|
||||
{
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _hashSet.Contains(i));
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _hashSet.Contains(i); });
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void DictionaryLookup()
|
||||
{
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _dictionary.ContainsKey(i));
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _dictionary.ContainsKey(i); });
|
||||
}
|
||||
|
||||
[Benchmark]
|
||||
public void ConcurrentDictionaryLookup()
|
||||
{
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _concurrentDictionary.ContainsKey(i));
|
||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _concurrentDictionary.ContainsKey(i); });
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue