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)]
|
[Orderer(SummaryOrderPolicy.FastestToSlowest)]
|
||||||
public class DataCacheBenchmark
|
public class DataCacheBenchmark
|
||||||
{
|
{
|
||||||
private ConcurrentDictionary<int, int> _concurrentDictionary;
|
private ConcurrentDictionary<int, int> _concurrentDictionary = null!;
|
||||||
private Dictionary<int, int> _dictionary;
|
private Dictionary<int, int> _dictionary = null!;
|
||||||
private HashSet<int> _hashSet;
|
private HashSet<int> _hashSet = null!;
|
||||||
private ImmutableHashSet<int> _immutableHashSet;
|
private ImmutableHashSet<int> _immutableHashSet = null!;
|
||||||
[Params(1000, 100000, 1000000)] public int N;
|
[Params(1000, 100000, 1000000)] public int N;
|
||||||
|
|
||||||
[GlobalSetup]
|
[GlobalSetup]
|
||||||
|
@ -63,24 +63,24 @@ public class DataCacheBenchmark
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void ImmutableHashSetLookup()
|
public void ImmutableHashSetLookup()
|
||||||
{
|
{
|
||||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _immutableHashSet.Contains(i));
|
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _immutableHashSet.Contains(i); });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void HashSetLookup()
|
public void HashSetLookup()
|
||||||
{
|
{
|
||||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _hashSet.Contains(i));
|
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _hashSet.Contains(i); });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void DictionaryLookup()
|
public void DictionaryLookup()
|
||||||
{
|
{
|
||||||
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => _dictionary.ContainsKey(i));
|
ParallelEnumerable.Range(0, N).AsParallel().ForAll(i => { _ = _dictionary.ContainsKey(i); });
|
||||||
}
|
}
|
||||||
|
|
||||||
[Benchmark]
|
[Benchmark]
|
||||||
public void ConcurrentDictionaryLookup()
|
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