Skip to content

Benchmarks

Performance comparison between source-generated and reflection-based dependency injection.

Key Takeaway

Source generation provides faster container build times compared to reflection. Service resolution performance is identical once the container is built.

Summary

Loading benchmark results...

Running Benchmarks Locally

cd src/NexusLabs.Needlr.Benchmarks
dotnet run -c Release -- --filter '*Build*'

To run all benchmarks:

dotnet run -c Release -- --filter '*'

CI Integration

Benchmarks run automatically:

  • Weekly: Every Sunday at 3am UTC (if code has changed)
  • On-demand: Via workflow dispatch

Results are published to this page after each run.

Methodology

All benchmarks use BenchmarkDotNet with:

  • ShortRun job: 3 warmup iterations, 3 target iterations
  • Memory diagnostics: Tracks allocations per operation
  • Baseline comparison: Reflection is always the baseline

Each benchmark class follows strict rules:

  1. One baseline per class (reflection approach)
  2. All methods in a class compare the same scenario
  3. Benchmark methods contain only what needs to be measured