mirror of
https://github.com/pese-git/cherrypick.git
synced 2026-01-24 13:47:24 +00:00
Add complex DI benchmarks, main runner, and English README with summarized results for cherrypick core
This commit is contained in:
37
benchmark_cherrypick/lib/cherrypick_benchmark.dart
Normal file
37
benchmark_cherrypick/lib/cherrypick_benchmark.dart
Normal file
@@ -0,0 +1,37 @@
|
||||
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() {
|
||||
scope = CherryPick.openRootScope();
|
||||
scope.installModules([AppModule()]);
|
||||
|
||||
}
|
||||
|
||||
@override
|
||||
void run() {
|
||||
scope.resolve<FooService>();
|
||||
}
|
||||
|
||||
@override
|
||||
void teardown() => CherryPick.closeRootScope();
|
||||
}
|
||||
|
||||
void main() {
|
||||
RegisterAndResolveBenchmark().report();
|
||||
}
|
||||
Reference in New Issue
Block a user