// ignore: depend_on_referenced_packages import 'package:benchmark_harness/benchmark_harness.dart'; import 'package:cherrypick/cherrypick.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().toProvideAsync(() async => AsyncA()).singleton(); bind().toProvideAsync(() async => AsyncB(await currentScope.resolveAsync())).singleton(); bind().toProvideAsync(() async => AsyncC(await currentScope.resolveAsync())).singleton(); } } class AsyncChainBenchmark extends AsyncBenchmarkBase { AsyncChainBenchmark() : super('AsyncChain (A->B->C, async)'); late Scope scope; @override Future setup() async { CherryPick.disableGlobalCycleDetection(); CherryPick.disableGlobalCrossScopeCycleDetection(); scope = CherryPick.openRootScope(); scope.installModules([AsyncChainModule()]); } @override Future teardown() async { CherryPick.closeRootScope(); } @override Future run() async { await scope.resolveAsync(); } }