mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 13:47:24 +00:00
- All benchmarks now use a unified base mixin for setup/teardown (BenchmarkWithScope). - Added args package support: CLI flags for choosing benchmarks, chain counts, nesting depths, output format. - Support for running benchmarks in matrix mode (multiple parameter sets). - Machine-readable output: csv, json, pretty-table. - Loop and naming lint fixes, unused imports removed.
51 lines
1.1 KiB
Dart
51 lines
1.1 KiB
Dart
// ignore: depend_on_referenced_packages
|
|
import 'package:benchmark_harness/benchmark_harness.dart';
|
|
import 'package:cherrypick/cherrypick.dart';
|
|
import 'benchmark_utils.dart';
|
|
|
|
class AsyncA {}
|
|
|
|
class AsyncB {
|
|
final AsyncA a;
|
|
AsyncB(this.a);
|
|
}
|
|
|
|
class AsyncC {
|
|
final AsyncB b;
|
|
AsyncC(this.b);
|
|
}
|
|
|
|
class AsyncChainModule extends Module {
|
|
@override
|
|
void builder(Scope currentScope) {
|
|
bind<AsyncA>().toProvideAsync(() async => AsyncA()).singleton();
|
|
bind<AsyncB>()
|
|
.toProvideAsync(
|
|
() async => AsyncB(await currentScope.resolveAsync<AsyncA>()))
|
|
.singleton();
|
|
bind<AsyncC>()
|
|
.toProvideAsync(
|
|
() async => AsyncC(await currentScope.resolveAsync<AsyncB>()))
|
|
.singleton();
|
|
}
|
|
}
|
|
|
|
class AsyncChainBenchmark extends AsyncBenchmarkBase with BenchmarkWithScope {
|
|
AsyncChainBenchmark() : super('AsyncChain (A->B->C, async)');
|
|
|
|
@override
|
|
Future<void> setup() async {
|
|
setupScope([AsyncChainModule()]);
|
|
}
|
|
|
|
@override
|
|
Future<void> teardown() async {
|
|
teardownScope();
|
|
}
|
|
|
|
@override
|
|
Future<void> run() async {
|
|
await scope.resolveAsync<AsyncC>();
|
|
}
|
|
}
|