Counting substrings - rianjs/DotNetPerfTesting GitHub Wiki

.NET 7 on Intel 64


BenchmarkDotNet=v0.13.5, OS=macOS Ventura 13.2.1 (22D68) [Darwin 22.3.0]
Intel Core i7-8850H CPU 2.60GHz (Coffee Lake), 1 CPU, 12 logical and 6 physical cores
.NET SDK=7.0.102
  [Host]     : .NET 7.0.2 (7.0.222.60605), X64 RyuJIT AVX2
  DefaultJob : .NET 7.0.2 (7.0.222.60605), X64 RyuJIT AVX2


Method Mean Error StdDev
CountSmallWithSplit 296.41 ns 2.498 ns 2.086 ns
CountBigWithSplit 159,989.45 ns 704.300 ns 549.871 ns
CountSmallWithCompiledRegex 89.85 ns 1.806 ns 1.774 ns
CountBigWithCompiledRegex 90.01 ns 1.625 ns 2.055 ns
CountSmallWithRegex 780.81 ns 13.430 ns 18.383 ns
CountBigWithRegex 758.57 ns 8.704 ns 7.268 ns
CountSmallWithStaticRegex 134.73 ns 1.508 ns 1.177 ns
CountBigWithStaticRegex 137.42 ns 1.684 ns 1.493 ns
SearchBigWithCompiledRegex 627,451.41 ns 11,926.929 ns 11,156.456 ns
SearchBigWithRegex 715.67 ns 12.196 ns 11.408 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 Gen0 Gen1 Allocated
CountSmallWithSplit 127.17 ns 3.639 ns 0.199 ns 0.0362 - 304 B
CountBigWithSplit 56,502.83 ns 4,542.992 ns 249.017 ns 13.2446 1.5259 111056 B
CountSmallWithCompiledRegex 41.60 ns 1.496 ns 0.082 ns 0.0249 - 208 B
CountBigWithCompiledRegex 41.70 ns 1.605 ns 0.088 ns 0.0249 - 208 B
CountSmallWithRegex 303.81 ns 2.785 ns 0.153 ns 0.2351 0.0010 1968 B
CountBigWithRegex 303.38 ns 1.723 ns 0.094 ns 0.2351 0.0010 1968 B
CountSmallWithStaticRegex 56.67 ns 0.528 ns 0.029 ns 0.0249 - 208 B
CountBigWithStaticRegex 56.57 ns 1.618 ns 0.089 ns 0.0249 - 208 B
SearchBigWithCompiledRegex 150,823.76 ns 34,404.570 ns 1,885.831 ns 0.7324 0.2441 7209 B
SearchBigWithRegex 305.27 ns 34.454 ns 1.889 ns 0.2351 0.0010 1968 B