From b78c7adf39c39672641355384302ad24def67eb3 Mon Sep 17 00:00:00 2001 From: Timothy Schenk Date: Wed, 21 Feb 2024 11:56:39 +0100 Subject: [PATCH] chore: minor adjustments to benchmarks --- Benchmarks/DataCacheBenchmark.cs | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Benchmarks/DataCacheBenchmark.cs b/Benchmarks/DataCacheBenchmark.cs index 5765fbe..e95a53c 100644 --- a/Benchmarks/DataCacheBenchmark.cs +++ b/Benchmarks/DataCacheBenchmark.cs @@ -11,10 +11,10 @@ namespace Benchmarks; [Orderer(SummaryOrderPolicy.FastestToSlowest)] public class DataCacheBenchmark { - private ConcurrentDictionary _concurrentDictionary; - private Dictionary _dictionary; - private HashSet _hashSet; - private ImmutableHashSet _immutableHashSet; + private ConcurrentDictionary _concurrentDictionary = null!; + private Dictionary _dictionary = null!; + private HashSet _hashSet = null!; + private ImmutableHashSet _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); }); } }