Skip to content

test: benchmark a mock that is used without any setup - #1003

Merged
vbreuss merged 1 commit into
mainfrom
test/unconfigured-benchmark
Nov 18, 2026
Merged

vbreuss merged 1 commit into
mainfrom
test/unconfigured-benchmark

Conversation

@vbreuss

@vbreuss vbreuss commented Nov 18, 2026

Copy link
Copy Markdown
Member

Calls that answer with a default value are the most common calls in a test suite, but no benchmark measured them: the complete workflow contains a single one.

Calls that answer with a default value are the most common calls in a test suite, but no benchmark measured them: the complete workflow contains a single one.
@vbreuss vbreuss self-assigned this Nov 18, 2026
@sonarqubecloud

Copy link
Copy Markdown

@vbreuss
vbreuss enabled auto-merge (squash) November 18, 2026 05:22
@github-actions

Copy link
Copy Markdown

Test Results

    47 files  ±0      47 suites  ±0   1h 4m 16s ⏱️ + 8m 0s
 4 796 tests ±0   4 796 ✅ ±0  0 💤 ±0  0 ❌ ±0 
48 368 runs  ±0  48 368 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit a6701cc. ± Comparison against base commit 5a69454.

This pull request removes 22 and adds 16 tests. Note that renamed tests count towards both.
 x-myHeader3: baz, True)
)
Mockolate.Internal.Tests.Internals.WildcardTests ‑ ShouldSupportMultilineStrings(
Mockolate.Internal.Tests.Internals.WildcardTests ‑ ShouldSupportMultilineStrings(
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(bool Equals(object obj);
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(bool Equals(object obj);
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ ShouldVerifyStringHeaders(x-myHeader1 : foo
Mockolate.Tests.Web.ItExtensionsTests+IsHttpContentTests+WithHeadersTests ‑ ShouldVerifyStringHeaders(x-myHeader1 : foo
…
Mockolate.Internal.Tests.Internals.WildcardTests ‑ ShouldSupportMultilineStrings(
)
Mockolate.Internal.Tests.Internals.WildcardTests ‑ ShouldSupportMultilineStrings(
)
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(bool Equals(object obj);
int GetHashCode();, public override bool Equals(object obj), public override int GetHashCode())
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(bool Equals(object obj);
int GetHashCode();, public override bool Equals(object obj), public override int GetHashCode())
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
bool Equals(object obj);, public override string ToString(), public override bool Equals(object obj))
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
bool Equals(object? obj);
int GetHashCode();, public override string ToString(), public override int GetHashCode(), public override bool Equals(object? obj))
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
int GetHashCode();, public override string ToString(), public override int GetHashCode())
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
bool Equals(object obj);, public override string ToString(), public override bool Equals(object obj))
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
bool Equals(object? obj);
int GetHashCode();, public override string ToString(), public override int GetHashCode(), public override bool Equals(object? obj))
Mockolate.SourceGenerators.Tests.MethodSetupsTests ‑ WhenImplementingObjectMethods_ShouldUseSpecialInterfaces(string ToString();
int GetHashCode();, public override string ToString(), public override int GetHashCode())
…

@vbreuss
vbreuss merged commit 1143b32 into main Nov 18, 2026
24 checks passed
@vbreuss
vbreuss deleted the test/unconfigured-benchmark branch November 18, 2026 05:27
@github-actions

Copy link
Copy Markdown

🚀 Benchmark Results

Compared to main @​ 5a694549: memory to the latest run, time to the median of the last 10 runs, as the runners differ in speed. A relative change marks when Mockolate gets more than 15% faster or slower relative to Imposter and TUnitMocks: 🔴 / 🟢 against both of them, 🔸 / 🔹 against only one.

CallbackBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Callback 196.8 ns → 271.2 ns (+38%) 952 B → 952 B 0.84× → 0.84× 1.95× → 2.14×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
INTEL XEON PLATINUM 8573C 3.03GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Callback Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 271.2 ns 3.88 ns 3.63 ns 1.00 952 B 1.00
Imposter 228.7 ns 2.46 ns 2.05 ns 0.84 616 B 0.65
TUnitMocks 579.7 ns 9.48 ns 8.87 ns 2.14 2056 B 2.16
Moq 45,197.1 ns 291.94 ns 273.08 ns 166.67 9145 B 9.61
NSubstitute 4,049.3 ns 36.89 ns 32.70 ns 14.93 7864 B 8.26
FakeItEasy 3,601.9 ns 39.15 ns 34.71 ns 13.28 6924 B 7.27

CompleteEventBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Event 180.5 ns → 144.3 ns (-20%) 864 B → 864 B 0.97× → 1.00× 0.86× → 0.86×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Event Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 144.3 ns 1.88 ns 1.67 ns 1.00 864 B 1.00
Imposter 144.6 ns 0.83 ns 0.65 ns 1.00 512 B 0.59
TUnitMocks 124.7 ns 2.52 ns 2.36 ns 0.86 1392 B 1.61
Moq 10,738.2 ns 122.16 ns 108.29 ns 74.44 12985 B 15.03
NSubstitute 4,083.8 ns 40.38 ns 37.77 ns 28.31 9192 B 10.64
FakeItEasy 194,610.1 ns 776.36 ns 688.22 ns 1,349.03 15619 B 18.08

CompleteIndexerBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Indexer (N=1) 605.0 ns → 556.2 ns (-8%) 2,320 B → 2,320 B 0.45× → 0.46× 1.10× → 1.06×
Indexer (N=10) 2.03 μs → 1.82 μs (-11%) 4,048 B → 4,048 B 0.32× → 0.34× 1.09× → 1.11×
Indexer (N=1000) 166.85 μs → 142.14 μs (-15%) 194,129 B → 194,129 B 0.27× → 0.27× 1.06× → 1.04×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Indexer N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 556.2 ns 17.27 ns 16.16 ns 1.00 2.27 KB 1.00
Imposter 1 256.1 ns 3.60 ns 3.01 ns 0.46 1.07 KB 0.47
TUnitMocks 1 587.8 ns 11.60 ns 10.85 ns 1.06 2.72 KB 1.20
Moq 1 139,317.8 ns 1,622.00 ns 1,354.45 ns 250.70 20.32 KB 8.97
NSubstitute 1 7,749.4 ns 89.17 ns 79.05 ns 13.94 12.73 KB 5.62
FakeItEasy 1 7,750.9 ns 146.66 ns 130.01 ns 13.95 13.27 KB 5.86
Mockolate 10 1,820.7 ns 26.91 ns 25.17 ns 1.00 3.95 KB 1.00
Imposter 10 617.7 ns 5.81 ns 4.86 ns 0.34 2.13 KB 0.54
TUnitMocks 10 2,017.2 ns 15.45 ns 14.46 ns 1.11 5.37 KB 1.36
Moq 10 147,275.3 ns 672.80 ns 561.82 ns 80.90 29.69 KB 7.51
NSubstitute 10 18,856.8 ns 162.63 ns 144.17 ns 10.36 25.52 KB 6.46
FakeItEasy 10 16,440.7 ns 357.01 ns 333.94 ns 9.03 32.47 KB 8.21
Mockolate 1000 142,142.4 ns 961.76 ns 899.63 ns 1.00 189.58 KB 1.00
Imposter 1000 38,777.7 ns 266.39 ns 222.45 ns 0.27 118.15 KB 0.62
TUnitMocks 1000 147,322.4 ns 3,317.90 ns 3,103.57 ns 1.04 293.67 KB 1.55
Moq 1000 749,385.9 ns 8,381.43 ns 7,840.00 ns 5.27 1006.45 KB 5.31
NSubstitute 1000 1,305,486.9 ns 11,401.28 ns 10,106.94 ns 9.18 1465.59 KB 7.73
FakeItEasy 1000 1,160,282.3 ns 26,470.16 ns 24,760.20 ns 8.16 2153 KB 11.36

CompleteMethodBenchmarks

✅ No changes in memory or relative performance (3 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Method (N=1) 212.6 ns → 284.8 ns (+34%) 1,040 B → 1,040 B 0.77× → 0.71× 2.00× → 1.94×
Method (N=10) 507.5 ns → 664.5 ns (+31%) 1,616 B → 1,616 B 0.62× → 0.61× 2.48× → 2.54×
Method (N=1000) 33.57 μs → 45.28 μs (+35%) 64,976 B → 64,976 B 0.53× → 0.50× 2.87× → 2.84×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
INTEL XEON PLATINUM 8573C 3.05GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Method N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 284.8 ns 4.64 ns 4.11 ns 1.00 1040 B 1.00
Imposter 1 201.0 ns 1.88 ns 1.76 ns 0.71 728 B 0.70
TUnitMocks 1 553.2 ns 5.25 ns 4.91 ns 1.94 2088 B 2.01
Moq 1 90,267.5 ns 425.00 ns 397.54 ns 316.96 14874 B 14.30
NSubstitute 1 5,504.2 ns 22.86 ns 19.09 ns 19.33 9320 B 8.96
FakeItEasy 1 4,506.2 ns 28.16 ns 26.34 ns 15.82 8153 B 7.84
Mockolate 10 664.5 ns 2.44 ns 2.16 ns 1.00 1616 B 1.00
Imposter 10 406.1 ns 1.80 ns 1.68 ns 0.61 1088 B 0.67
TUnitMocks 10 1,685.1 ns 7.29 ns 6.82 ns 2.54 3840 B 2.38
Moq 10 96,328.4 ns 407.56 ns 361.29 ns 144.97 18883 B 11.69
NSubstitute 10 7,943.4 ns 36.14 ns 30.18 ns 11.95 12344 B 7.64
FakeItEasy 10 7,704.8 ns 70.81 ns 66.24 ns 11.60 16393 B 10.14
Mockolate 1000 45,275.4 ns 188.04 ns 166.69 ns 1.00 64976 B 1.00
Imposter 1000 22,681.1 ns 93.70 ns 87.65 ns 0.50 40688 B 0.63
TUnitMocks 1000 128,677.0 ns 717.38 ns 671.04 ns 2.84 203585 B 3.13
Moq 1000 292,932.8 ns 2,741.23 ns 2,289.05 ns 6.47 431907 B 6.65
NSubstitute 1000 244,665.1 ns 1,709.02 ns 1,598.62 ns 5.40 378020 B 5.82
FakeItEasy 1000 362,143.5 ns 1,098.80 ns 1,027.82 ns 8.00 944362 B 14.53

CompletePropertyBenchmarks

Relative performance (how many times as long the other library takes as Mockolate, main → PR)

Benchmark vs Imposter vs TUnitMocks
Property (N=1000) 0.29× → 0.35× 🔹 -18% 1.97× → 2.23×
All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Property (N=1) 311.6 ns → 321.3 ns (+3%) 1,208 B → 1,208 B 0.51× → 0.49× 1.31× → 1.24×
Property (N=10) 812.8 ns → 780.1 ns (-4%) 2,216 B → 2,216 B 0.38× → 0.42× 1.81× → 1.90×
Property (N=1000) 57.25 μs → 50.79 μs (-11%) 113,096 B → 113,096 B 0.29× → 0.35× 🔹 -18% 1.97× → 2.23×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Property N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 321.3 ns 7.19 ns 6.73 ns 1.00 1208 B 1.00
Imposter 1 156.8 ns 8.20 ns 7.67 ns 0.49 672 B 0.56
TUnitMocks 1 400.0 ns 9.51 ns 8.43 ns 1.25 1672 B 1.38
Moq 1 6,884.9 ns 12.66 ns 10.57 ns 21.44 10568 B 8.75
NSubstitute 1 5,269.1 ns 67.24 ns 62.90 ns 16.41 11664 B 9.66
FakeItEasy 1 4,634.3 ns 53.42 ns 49.97 ns 14.43 11191 B 9.26
Mockolate 10 780.1 ns 10.03 ns 8.89 ns 1.00 2216 B 1.00
Imposter 10 328.8 ns 1.25 ns 1.11 ns 0.42 960 B 0.43
TUnitMocks 10 1,481.2 ns 31.15 ns 29.14 ns 1.90 4024 B 1.82
Moq 10 11,361.6 ns 115.86 ns 108.38 ns 14.57 18504 B 8.35
NSubstitute 10 11,610.0 ns 219.30 ns 205.14 ns 14.88 21528 B 9.71
FakeItEasy 10 11,141.1 ns 161.77 ns 151.32 ns 14.28 30780 B 13.89
Mockolate 1000 50,789.7 ns 355.73 ns 297.05 ns 1.00 113096 B 1.00
Imposter 1000 17,841.5 ns 112.21 ns 104.96 ns 0.35 32640 B 0.29
TUnitMocks 1000 113,282.4 ns 4,038.91 ns 3,778.00 ns 2.23 242489 B 2.14
Moq 1000 436,529.2 ns 3,611.35 ns 3,201.37 ns 8.60 836449 B 7.40
NSubstitute 1000 679,696.3 ns 8,273.52 ns 6,908.76 ns 13.38 1139620 B 10.08
FakeItEasy 1000 753,958.4 ns 19,086.03 ns 17,853.09 ns 14.85 2194285 B 19.40

CompleteUnconfiguredBenchmarks

✅ No changes in memory or relative performance (0 benchmarks)

New, without results on main: Unconfigured (N=1), Unconfigured (N=10), Unconfigured (N=1000)

Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Unconfigured N Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1 683.4 ns 3.91 ns 3.65 ns 1.00 2.23 KB 1.00
Imposter 1 247.4 ns 3.71 ns 3.29 ns 0.36 1.06 KB 0.48
TUnitMocks 1 490.4 ns 15.41 ns 14.42 ns 0.72 1.81 KB 0.81
Moq 1 37,140.6 ns 119.47 ns 99.77 ns 54.35 9.77 KB 4.39
NSubstitute 1 5,554.2 ns 47.02 ns 43.98 ns 8.13 10.01 KB 4.49
FakeItEasy 1 4,879.6 ns 114.61 ns 107.20 ns 7.14 11.57 KB 5.20
Mockolate 10 2,936.1 ns 41.14 ns 38.49 ns 1.00 8.44 KB 1.00
Imposter 10 764.3 ns 3.39 ns 3.00 ns 0.26 2.89 KB 0.34
TUnitMocks 10 2,796.7 ns 8.54 ns 7.57 ns 0.95 8.47 KB 1.00
Moq 10 49,789.6 ns 1,117.77 ns 1,045.57 ns 16.96 24.52 KB 2.91
NSubstitute 10 14,378.5 ns 105.73 ns 98.90 ns 4.90 22.93 KB 2.72
FakeItEasy 10 18,139.0 ns 130.66 ns 122.22 ns 6.18 53.92 KB 6.39
Mockolate 1000 254,072.4 ns 513.80 ns 429.05 ns 1.00 689.06 KB 1.00
Imposter 1000 64,406.1 ns 151.11 ns 126.18 ns 0.25 203.99 KB 0.30
TUnitMocks 1000 258,933.0 ns 1,010.33 ns 895.63 ns 1.02 691.21 KB 1.00
Moq 1000 917,243.2 ns 6,036.61 ns 5,646.65 ns 3.61 1652.89 KB 2.40
NSubstitute 1000 955,132.0 ns 4,989.49 ns 4,667.17 ns 3.76 1434.37 KB 2.08
FakeItEasy 1000 1,848,835.2 ns 84,954.64 ns 79,466.63 ns 7.28 4690.6 KB 6.81

CompleteWorkflowBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
Complete 1.50 μs → 1.27 μs (-15%) 4,232 B → 4,232 B 0.71× → 0.74× 2.12× → 1.97×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
Intel Xeon 6975P-C 2.70GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

Complete Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 1,271.8 ns 40.62 ns 38.00 ns 1.00 4.13 KB 1.00
Imposter 946.2 ns 14.81 ns 13.13 ns 0.74 3.17 KB 0.77
TUnitMocks 2,503.6 ns 43.61 ns 38.66 ns 1.97 10.3 KB 2.49
Moq 202,327.9 ns 1,322.58 ns 1,172.43 ns 159.23 46.28 KB 11.20
NSubstitute 19,341.8 ns 62.31 ns 58.28 ns 15.22 36.69 KB 8.88
FakeItEasy 15,954.8 ns 311.24 ns 291.14 ns 12.56 34.27 KB 8.29

MockCreationBenchmarks

✅ No changes in memory or relative performance (1 benchmarks)

All benchmarks compared to main
Benchmark Time Memory vs Imposter vs TUnitMocks
CreateMock 16.0 ns → 13.2 ns (-18%) 160 B → 160 B 5.53× → 5.97× 1.67× → 1.65×
Raw results
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon)
AMD EPYC 9V74 3.69GHz, 1 CPU, 4 logical and 2 physical cores
.NET SDK 11.0.100
  [Host] : .NET 11.0.0 (11.0.0, 11.0.26.53018), X64 RyuJIT x86-64-v4

Job=InProcess  Toolchain=InProcessEmitToolchain  IterationCount=15  
LaunchCount=1  WarmupCount=10  

CreateMock Mean Error StdDev Ratio Allocated Alloc Ratio
Mockolate 13.19 ns 0.155 ns 0.130 ns 1.00 160 B 1.00
Imposter 78.77 ns 1.477 ns 1.233 ns 5.97 504 B 3.15
TUnitMocks 21.76 ns 0.219 ns 0.205 ns 1.65 216 B 1.35
Moq 1,028.98 ns 10.024 ns 8.371 ns 78.02 2088 B 13.05
NSubstitute 1,422.61 ns 39.741 ns 35.229 ns 107.86 5032 B 31.45
FakeItEasy 1,334.05 ns 45.330 ns 42.401 ns 101.15 2755 B 17.22

github-actions Bot added a commit that referenced this pull request Nov 18, 2026
github-actions Bot added a commit that referenced this pull request Nov 18, 2026
@github-actions

Copy link
Copy Markdown

This is addressed in release v4.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

state: released The issue is released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant