Synchronization methods - rianjs/DotNetPerfTesting GitHub Wiki

Tests:

.NET Core 2.2 on Intel 64


BenchmarkDotNet=v0.10.14, OS=macOS 10.15.3 (19D76) [Darwin 19.3.0]
Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET Core SDK=2.2.100
  [Host] : .NET Core 2.2.0 (CoreCLR 4.6.27110.04, CoreFX 4.6.27110.04), 64bit RyuJIT


Method Mean Error StdDev Median
SemaphoreSlimValueExists 101.01 ns 2.9364 ns 8.6581 ns 98.99 ns
LockDictionaryValueExists 36.27 ns 0.5430 ns 0.4240 ns 36.26 ns
DictionaryValueExists 24.57 ns 0.7112 ns 2.0746 ns 23.98 ns

.NET 8 on M3 Mac


BenchmarkDotNet v0.13.12, macOS Sonoma 14.4 (23E214) [Darwin 23.4.0]
Apple M3, 1 CPU, 8 logical and 8 physical cores
.NET SDK 8.0.100
  [Host]   : .NET 8.0.0 (8.0.23.53103), Arm64 RyuJIT AdvSIMD
  ShortRun : .NET 8.0.0 (8.0.23.53103), Arm64 RyuJIT AdvSIMD

Job=ShortRun  IterationCount=3  LaunchCount=1  
WarmupCount=3  

Method Mean Error StdDev Allocated
SemaphoreSlimValueExists 19.059 ns 1.7578 ns 0.0964 ns -
LockDictionaryValueExists 8.662 ns 0.0340 ns 0.0019 ns -
DictionaryValueExists 4.965 ns 0.1640 ns 0.0090 ns -