mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-25 05:59:55 +00:00
refactor(benchmarks): unify benchmark structure, enable CLI parameterization, run matrix, add CSV/JSON/pretty output
- 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.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
// 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);
|
||||
@@ -16,26 +19,30 @@ 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();
|
||||
bind<AsyncB>()
|
||||
.toProvideAsync(
|
||||
() async => AsyncB(await currentScope.resolveAsync<AsyncA>()))
|
||||
.singleton();
|
||||
bind<AsyncC>()
|
||||
.toProvideAsync(
|
||||
() async => AsyncC(await currentScope.resolveAsync<AsyncB>()))
|
||||
.singleton();
|
||||
}
|
||||
}
|
||||
|
||||
class AsyncChainBenchmark extends AsyncBenchmarkBase {
|
||||
class AsyncChainBenchmark extends AsyncBenchmarkBase with BenchmarkWithScope {
|
||||
AsyncChainBenchmark() : super('AsyncChain (A->B->C, async)');
|
||||
late Scope scope;
|
||||
|
||||
@override
|
||||
Future<void> setup() async {
|
||||
CherryPick.disableGlobalCycleDetection();
|
||||
CherryPick.disableGlobalCrossScopeCycleDetection();
|
||||
scope = CherryPick.openRootScope();
|
||||
scope.installModules([AsyncChainModule()]);
|
||||
setupScope([AsyncChainModule()]);
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> teardown() async {
|
||||
CherryPick.closeRootScope();
|
||||
teardownScope();
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> run() async {
|
||||
await scope.resolveAsync<AsyncC>();
|
||||
|
||||
Reference in New Issue
Block a user