| OLD | NEW |
| 1 library di.injector_benchmark_common; | 1 library di.injector_benchmark_common; |
| 2 | 2 |
| 3 import 'package:benchmark_harness/benchmark_harness.dart'; | 3 import 'package:benchmark_harness/benchmark_harness.dart'; |
| 4 import 'package:di/di.dart'; | 4 import 'package:di/di.dart'; |
| 5 | 5 |
| 6 int count = 0; |
| 7 |
| 6 class InjectorBenchmark extends BenchmarkBase { | 8 class InjectorBenchmark extends BenchmarkBase { |
| 7 var injectorFactory; | 9 var injectorFactory; |
| 8 var module; | 10 var module; |
| 9 | 11 |
| 10 InjectorBenchmark(name, this.injectorFactory) : super(name); | 12 InjectorBenchmark(name, this.injectorFactory) : super(name); |
| 11 | 13 |
| 12 void run() { | 14 void run() { |
| 13 Injector injector = injectorFactory([module]); | 15 Injector injector = injectorFactory([module]); |
| 14 injector.get(A); | 16 injector.get(A); |
| 15 injector.get(B); | 17 injector.get(B); |
| 16 | 18 |
| 17 var childInjector = injector.createChild([module]); | 19 var childInjector = injector.createChild([module]); |
| 18 childInjector.get(A); | 20 childInjector.get(A); |
| 19 childInjector.get(B); | 21 childInjector.get(B); |
| 20 } | 22 } |
| 21 | 23 |
| 22 setup() { | 24 setup() { |
| 23 module = new Module() | 25 module = new Module() |
| 24 ..type(A) | 26 ..type(A) |
| 25 ..type(B) | 27 ..type(B) |
| 26 ..type(C) | 28 ..type(C) |
| 27 ..type(D) | 29 ..type(D) |
| 28 ..type(E); | 30 ..type(E); |
| 29 } | 31 } |
| 32 |
| 33 teardown() { |
| 34 print(count); |
| 35 } |
| 30 } | 36 } |
| 31 | 37 |
| 32 class A { | 38 class A { |
| 33 A(B b, C c); | 39 A(B b, C c) { |
| 40 count++; |
| 41 } |
| 34 } | 42 } |
| 35 | 43 |
| 36 class B { | 44 class B { |
| 37 B(D b, E c); | 45 B(D b, E c) { |
| 46 count++; |
| 47 } |
| 38 } | 48 } |
| 39 | 49 |
| 40 class C { | 50 class C { |
| 51 C() { |
| 52 count++; |
| 53 } |
| 41 } | 54 } |
| 42 | 55 |
| 43 class D { | 56 class D { |
| 57 D() { |
| 58 count++; |
| 59 } |
| 44 } | 60 } |
| 45 | 61 |
| 46 class E { | 62 class E { |
| 63 E() { |
| 64 count++; |
| 65 } |
| 47 } | 66 } |
| OLD | NEW |