mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 13:47:24 +00:00
40 lines
850 B
Dart
40 lines
850 B
Dart
import 'package:benchmark_harness/benchmark_harness.dart';
|
|
import 'package:cherrypick/cherrypick.dart';
|
|
|
|
class AppModule extends Module {
|
|
@override
|
|
void builder(Scope currentScope) {
|
|
bind<FooService>().toProvide(() => FooService());
|
|
}
|
|
|
|
}
|
|
|
|
// Dummy service for DI
|
|
class FooService {}
|
|
|
|
class RegisterAndResolveBenchmark extends BenchmarkBase {
|
|
RegisterAndResolveBenchmark() : super('RegisterAndResolve');
|
|
late final Scope scope;
|
|
|
|
@override
|
|
void setup() {
|
|
CherryPick.disableGlobalCycleDetection();
|
|
CherryPick.disableGlobalCrossScopeCycleDetection();
|
|
scope = CherryPick.openRootScope();
|
|
scope.installModules([AppModule()]);
|
|
|
|
}
|
|
|
|
@override
|
|
void run() {
|
|
scope.resolve<FooService>();
|
|
}
|
|
|
|
@override
|
|
void teardown() => CherryPick.closeRootScope();
|
|
}
|
|
|
|
void main() {
|
|
RegisterAndResolveBenchmark().report();
|
|
}
|