Counting substrings - rianjs/DotNetPerfTesting GitHub Wiki


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