mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
1.7 KiB
1.7 KiB
benchmark_cherrypick
Benchmarks for performance and features of the cherrypick (core) DI container.
All scenarios use the public API capabilities of cherrypick (scope, module, binding, scoping, and async support).
Scenarios
- RegisterAndResolve: basic registration and resolution of a dependency.
- ChainSingleton (A->B->C, singleton): dependency chain, all as singletons.
- ChainFactory (A->B->C, factory): dependency chain with factory bindings (new instance on each request).
- NamedResolve (by name): resolving a named dependency among multiple implementations.
- AsyncChain (A->B->C, async): asynchronous dependency chain.
- ScopeOverride (child overrides parent): overriding a dependency in a child scope over a parent.
Benchmark results
| Scenario | RunTime (μs) |
|---|---|
| RegisterAndResolve | 0.1976 |
| ChainSingleton (A->B->C, singleton) | 0.2721 |
| ChainFactory (A->B->C, factory) | 0.6690 |
| NamedResolve (by name) | 0.2018 |
| AsyncChain (A->B->C, async) | 1.2732 |
| ScopeOverride (child overrides parent) | 0.1962 |
How to run
- Get dependencies:
dart pub get - Run the benchmarks:
dart run bin/main.dart
A text report with all metrics will be displayed in the console.
To add your custom scenario — just create a new Dart file and declare a class extending BenchmarkBase or AsyncBenchmarkBase, then add its invocation to main.dart.