Benchmarks¶
Overview of performance measurements using BenchmarkDotNet. The suite compares Imposter with popular impersonation libraries for common setup and invocation patterns.
What’s Measured¶
- Setup throughput: configuring return values for a simple method.
- Invocation throughput: calling the configured method.
- Parameterized iterations: 1, 10, 100, 1000 setups + calls.
Primary scenario (see benchmarks/Imposter.Benchmarks/ImposterVsAlternatives/SimpleMethodMockingBenchmarks.cs), run with Moq, NSubstitute, FakeItEasy, Rocks and Imposter:
public interface ICalculator { int Square(int input); }
Additional microbenchmarks cover generator internals (syntax builders) and struct behaviors.
Benchmark Results¶
The Benchmarks workflow reruns this comparison on a GitHub-hosted runner after every change to the code on master, so the table always shows the latest build. Shared runners are slower and noisier than a desktop machine: compare the libraries within the table rather than the absolute timings. Allocations are exact.
The same results are available as Markdown and as the BenchmarkDotNet JSON report.
Run Locally¶
dotnet run -c Release --project benchmarks/Imposter.Benchmarks/Imposter.Benchmarks.csproj -p:ROSLYN_VERSION=5.0
This runs the comparison above. Pass a filter to run another benchmark, for example -- --filter *ComplexMethodMockingBenchmark*. BenchmarkDotNet writes its reports (Markdown, CSV, HTML and JSON) to BenchmarkDotNet.Artifacts/ in the directory you run it from.