mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-23 21:13:35 +00:00
Add complex DI benchmarks, main runner, and English README with summarized results for cherrypick core
This commit is contained in:
42
benchmark_cherrypick/README.md
Normal file
42
benchmark_cherrypick/README.md
Normal file
@@ -0,0 +1,42 @@
|
||||
# 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
|
||||
|
||||
1. Get dependencies:
|
||||
```shell
|
||||
dart pub get
|
||||
```
|
||||
2. Run the benchmarks:
|
||||
```shell
|
||||
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.
|
||||
Reference in New Issue
Block a user