| OLD | NEW |
| 1 library angular.perf.watch_group; | 1 library angular.perf.watch_group; |
| 2 | 2 |
| 3 import '_perf.dart'; | 3 import '_perf.dart'; |
| 4 import 'package:angular/change_detection/dirty_checking_change_detector.dart'; | 4 import 'package:angular/change_detection/dirty_checking_change_detector.dart'; |
| 5 import 'package:angular/change_detection/dirty_checking_change_detector_dynamic.
dart'; | |
| 6 import 'package:angular/change_detection/dirty_checking_change_detector_static.d
art'; | |
| 7 import 'package:angular/change_detection/watch_group.dart'; | 5 import 'package:angular/change_detection/watch_group.dart'; |
| 8 import 'package:benchmark_harness/benchmark_harness.dart'; | 6 import 'package:benchmark_harness/benchmark_harness.dart'; |
| 9 | 7 |
| 10 @MirrorsUsed( | 8 @MirrorsUsed( |
| 11 targets: const [ | 9 targets: const [ |
| 12 'angular.perf.watch_group' | 10 'angular.perf.watch_group' |
| 13 ], | 11 ], |
| 14 override: '*' | 12 override: '*' |
| 15 ) | 13 ) |
| 16 import 'dart:mirrors' show MirrorsUsed; | 14 import 'dart:mirrors' show MirrorsUsed; |
| 17 | 15 |
| 18 var _reactionFn = (_, __) => null; | 16 var _reactionFn = (_, __) => null; |
| 19 var _staticFieldGetterFactory = new StaticFieldGetterFactory({ | 17 var _getterCache = new GetterCache({}); |
| 20 "a": (o) => o.a, "b": (o) => o.b, "c": (o) => o.c, "d": (o) => o.d, "e": (o)
=> o.e, | |
| 21 "f": (o) => o.f, "g": (o) => o.g, "h": (o) => o.h, "i": (o) => o.i, "j": (o)
=> o.j, | |
| 22 "k": (o) => o.k, "l": (o) => o.l, "m": (o) => o.m, "n": (o) => o.n, "o": (o)
=> o.o, | |
| 23 "p": (o) => o.p, "q": (o) => o.q, "r": (o) => o.r, "s": (o) => o.s, "t": (o)
=> o.t, | |
| 24 }); | |
| 25 var _dynamicFieldGetterFactory = new DynamicFieldGetterFactory(); | |
| 26 | |
| 27 main() { | 18 main() { |
| 28 _fieldRead(); | 19 _fieldRead(); |
| 29 _fieldReadGetter(); | 20 _fieldReadGetter(); |
| 30 _mapRead(); | 21 _mapRead(); |
| 31 _methodInvoke0(); | 22 _methodInvoke0(); |
| 32 _methodInvoke1(); | 23 _methodInvoke1(); |
| 33 _function2(); | 24 _function2(); |
| 34 new _CollectionCheck().report(); | 25 new _CollectionCheck().report(); |
| 35 } | 26 } |
| 36 | 27 |
| 37 class _CollectionCheck extends BenchmarkBase { | 28 class _CollectionCheck extends BenchmarkBase { |
| 38 List<int> list = new List.generate(1000, (i) => i); | 29 List<int> list = new List.generate(1000, (i) => i); |
| 39 var detector = new DirtyCheckingChangeDetector(_dynamicFieldGetterFactory); | 30 var detector = new DirtyCheckingChangeDetector(_getterCache); |
| 40 | 31 |
| 41 _CollectionCheck(): super('change-detect List[1000]') { | 32 _CollectionCheck(): super('change-detect List[1000]') { |
| 42 detector | 33 detector |
| 43 ..watch(list, null, 'handler') | 34 ..watch(list, null, 'handler') |
| 44 ..collectChanges(); // intialize | 35 ..collectChanges(); // intialize |
| 45 } | 36 } |
| 46 | 37 |
| 47 run() { | 38 run() { |
| 48 detector.collectChanges(); | 39 detector.collectChanges(); |
| 49 } | 40 } |
| 50 } | 41 } |
| 51 | 42 |
| 52 _fieldRead() { | 43 _fieldRead() { |
| 53 var watchGrp = new RootWatchGroup(_dynamicFieldGetterFactory, | 44 var watchGrp = new RootWatchGroup( |
| 54 new DirtyCheckingChangeDetector(_dynamicFieldGetterFactory), new _Obj()) | 45 new DirtyCheckingChangeDetector(_getterCache), new _Obj()) |
| 55 ..watch(_parse('a'), _reactionFn) | 46 ..watch(_parse('a'), _reactionFn) |
| 56 ..watch(_parse('b'), _reactionFn) | 47 ..watch(_parse('b'), _reactionFn) |
| 57 ..watch(_parse('c'), _reactionFn) | 48 ..watch(_parse('c'), _reactionFn) |
| 58 ..watch(_parse('d'), _reactionFn) | 49 ..watch(_parse('d'), _reactionFn) |
| 59 ..watch(_parse('e'), _reactionFn) | 50 ..watch(_parse('e'), _reactionFn) |
| 60 ..watch(_parse('f'), _reactionFn) | 51 ..watch(_parse('f'), _reactionFn) |
| 61 ..watch(_parse('g'), _reactionFn) | 52 ..watch(_parse('g'), _reactionFn) |
| 62 ..watch(_parse('h'), _reactionFn) | 53 ..watch(_parse('h'), _reactionFn) |
| 63 ..watch(_parse('i'), _reactionFn) | 54 ..watch(_parse('i'), _reactionFn) |
| 64 ..watch(_parse('j'), _reactionFn) | 55 ..watch(_parse('j'), _reactionFn) |
| 65 ..watch(_parse('k'), _reactionFn) | 56 ..watch(_parse('k'), _reactionFn) |
| 66 ..watch(_parse('l'), _reactionFn) | 57 ..watch(_parse('l'), _reactionFn) |
| 67 ..watch(_parse('m'), _reactionFn) | 58 ..watch(_parse('m'), _reactionFn) |
| 68 ..watch(_parse('n'), _reactionFn) | 59 ..watch(_parse('n'), _reactionFn) |
| 69 ..watch(_parse('o'), _reactionFn) | 60 ..watch(_parse('o'), _reactionFn) |
| 70 ..watch(_parse('p'), _reactionFn) | 61 ..watch(_parse('p'), _reactionFn) |
| 71 ..watch(_parse('q'), _reactionFn) | 62 ..watch(_parse('q'), _reactionFn) |
| 72 ..watch(_parse('r'), _reactionFn) | 63 ..watch(_parse('r'), _reactionFn) |
| 73 ..watch(_parse('s'), _reactionFn) | 64 ..watch(_parse('s'), _reactionFn) |
| 74 ..watch(_parse('t'), _reactionFn); | 65 ..watch(_parse('t'), _reactionFn); |
| 75 | 66 |
| 76 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); | 67 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); |
| 77 | 68 |
| 78 time('fieldRead', () => watchGrp.detectChanges()); | 69 time('fieldRead', () => watchGrp.detectChanges()); |
| 79 } | 70 } |
| 80 | 71 |
| 81 _fieldReadGetter() { | 72 _fieldReadGetter() { |
| 82 var watchGrp= new RootWatchGroup(_staticFieldGetterFactory, | 73 var getterCache = new GetterCache({ |
| 83 new DirtyCheckingChangeDetector(_staticFieldGetterFactory), new _Obj()) | 74 "a": (o) => o.a, "b": (o) => o.b, "c": (o) => o.c, "d": (o) => o.d, "e": (o)
=> o.e, |
| 75 "f": (o) => o.f, "g": (o) => o.g, "h": (o) => o.h, "i": (o) => o.i, "j": (o)
=> o.j, |
| 76 "k": (o) => o.k, "l": (o) => o.l, "m": (o) => o.m, "n": (o) => o.n, "o": (o)
=> o.o, |
| 77 "p": (o) => o.p, "q": (o) => o.q, "r": (o) => o.r, "s": (o) => o.s, "t": (o)
=> o.t, |
| 78 }); |
| 79 var watchGrp= new RootWatchGroup( |
| 80 new DirtyCheckingChangeDetector(getterCache), new _Obj()) |
| 84 ..watch(_parse('a'), _reactionFn) | 81 ..watch(_parse('a'), _reactionFn) |
| 85 ..watch(_parse('b'), _reactionFn) | 82 ..watch(_parse('b'), _reactionFn) |
| 86 ..watch(_parse('c'), _reactionFn) | 83 ..watch(_parse('c'), _reactionFn) |
| 87 ..watch(_parse('d'), _reactionFn) | 84 ..watch(_parse('d'), _reactionFn) |
| 88 ..watch(_parse('e'), _reactionFn) | 85 ..watch(_parse('e'), _reactionFn) |
| 89 ..watch(_parse('f'), _reactionFn) | 86 ..watch(_parse('f'), _reactionFn) |
| 90 ..watch(_parse('g'), _reactionFn) | 87 ..watch(_parse('g'), _reactionFn) |
| 91 ..watch(_parse('h'), _reactionFn) | 88 ..watch(_parse('h'), _reactionFn) |
| 92 ..watch(_parse('i'), _reactionFn) | 89 ..watch(_parse('i'), _reactionFn) |
| 93 ..watch(_parse('j'), _reactionFn) | 90 ..watch(_parse('j'), _reactionFn) |
| (...skipping 12 matching lines...) Expand all Loading... |
| 106 | 103 |
| 107 time('fieldReadGetter', () => watchGrp.detectChanges()); | 104 time('fieldReadGetter', () => watchGrp.detectChanges()); |
| 108 } | 105 } |
| 109 | 106 |
| 110 _mapRead() { | 107 _mapRead() { |
| 111 var map = { | 108 var map = { |
| 112 'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, | 109 'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, |
| 113 'f': 0, 'g': 1, 'h': 2, 'i': 3, 'j': 4, | 110 'f': 0, 'g': 1, 'h': 2, 'i': 3, 'j': 4, |
| 114 'k': 0, 'l': 1, 'm': 2, 'n': 3, 'o': 4, | 111 'k': 0, 'l': 1, 'm': 2, 'n': 3, 'o': 4, |
| 115 'p': 0, 'q': 1, 'r': 2, 's': 3, 't': 4}; | 112 'p': 0, 'q': 1, 'r': 2, 's': 3, 't': 4}; |
| 116 var watchGrp = new RootWatchGroup(_dynamicFieldGetterFactory, | 113 var watchGrp = new RootWatchGroup( |
| 117 new DirtyCheckingChangeDetector(_dynamicFieldGetterFactory), map) | 114 new DirtyCheckingChangeDetector(_getterCache), map) |
| 118 ..watch(_parse('a'), _reactionFn) | 115 ..watch(_parse('a'), _reactionFn) |
| 119 ..watch(_parse('b'), _reactionFn) | 116 ..watch(_parse('b'), _reactionFn) |
| 120 ..watch(_parse('c'), _reactionFn) | 117 ..watch(_parse('c'), _reactionFn) |
| 121 ..watch(_parse('d'), _reactionFn) | 118 ..watch(_parse('d'), _reactionFn) |
| 122 ..watch(_parse('e'), _reactionFn) | 119 ..watch(_parse('e'), _reactionFn) |
| 123 ..watch(_parse('f'), _reactionFn) | 120 ..watch(_parse('f'), _reactionFn) |
| 124 ..watch(_parse('g'), _reactionFn) | 121 ..watch(_parse('g'), _reactionFn) |
| 125 ..watch(_parse('h'), _reactionFn) | 122 ..watch(_parse('h'), _reactionFn) |
| 126 ..watch(_parse('i'), _reactionFn) | 123 ..watch(_parse('i'), _reactionFn) |
| 127 ..watch(_parse('j'), _reactionFn) | 124 ..watch(_parse('j'), _reactionFn) |
| 128 ..watch(_parse('k'), _reactionFn) | 125 ..watch(_parse('k'), _reactionFn) |
| 129 ..watch(_parse('l'), _reactionFn) | 126 ..watch(_parse('l'), _reactionFn) |
| 130 ..watch(_parse('m'), _reactionFn) | 127 ..watch(_parse('m'), _reactionFn) |
| 131 ..watch(_parse('n'), _reactionFn) | 128 ..watch(_parse('n'), _reactionFn) |
| 132 ..watch(_parse('o'), _reactionFn) | 129 ..watch(_parse('o'), _reactionFn) |
| 133 ..watch(_parse('p'), _reactionFn) | 130 ..watch(_parse('p'), _reactionFn) |
| 134 ..watch(_parse('q'), _reactionFn) | 131 ..watch(_parse('q'), _reactionFn) |
| 135 ..watch(_parse('r'), _reactionFn) | 132 ..watch(_parse('r'), _reactionFn) |
| 136 ..watch(_parse('s'), _reactionFn) | 133 ..watch(_parse('s'), _reactionFn) |
| 137 ..watch(_parse('t'), _reactionFn); | 134 ..watch(_parse('t'), _reactionFn); |
| 138 | 135 |
| 139 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); | 136 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); |
| 140 time('mapRead', () => watchGrp.detectChanges()); | 137 time('mapRead', () => watchGrp.detectChanges()); |
| 141 } | 138 } |
| 142 | 139 |
| 143 _methodInvoke0() { | 140 _methodInvoke0() { |
| 144 var context = new _Obj(); | 141 var context = new _Obj(); |
| 145 context.a = new _Obj(); | 142 context.a = new _Obj(); |
| 146 var watchGrp = new RootWatchGroup(_dynamicFieldGetterFactory, | 143 var watchGrp = new RootWatchGroup( |
| 147 new DirtyCheckingChangeDetector(_dynamicFieldGetterFactory), context) | 144 new DirtyCheckingChangeDetector(_getterCache), context) |
| 148 ..watch(_method('a', 'methodA'), _reactionFn) | 145 ..watch(_method('a', 'methodA'), _reactionFn) |
| 149 ..watch(_method('a', 'methodB'), _reactionFn) | 146 ..watch(_method('a', 'methodB'), _reactionFn) |
| 150 ..watch(_method('a', 'methodC'), _reactionFn) | 147 ..watch(_method('a', 'methodC'), _reactionFn) |
| 151 ..watch(_method('a', 'methodD'), _reactionFn) | 148 ..watch(_method('a', 'methodD'), _reactionFn) |
| 152 ..watch(_method('a', 'methodE'), _reactionFn) | 149 ..watch(_method('a', 'methodE'), _reactionFn) |
| 153 ..watch(_method('a', 'methodF'), _reactionFn) | 150 ..watch(_method('a', 'methodF'), _reactionFn) |
| 154 ..watch(_method('a', 'methodG'), _reactionFn) | 151 ..watch(_method('a', 'methodG'), _reactionFn) |
| 155 ..watch(_method('a', 'methodH'), _reactionFn) | 152 ..watch(_method('a', 'methodH'), _reactionFn) |
| 156 ..watch(_method('a', 'methodI'), _reactionFn) | 153 ..watch(_method('a', 'methodI'), _reactionFn) |
| 157 ..watch(_method('a', 'methodJ'), _reactionFn) | 154 ..watch(_method('a', 'methodJ'), _reactionFn) |
| 158 ..watch(_method('a', 'methodK'), _reactionFn) | 155 ..watch(_method('a', 'methodK'), _reactionFn) |
| 159 ..watch(_method('a', 'methodL'), _reactionFn) | 156 ..watch(_method('a', 'methodL'), _reactionFn) |
| 160 ..watch(_method('a', 'methodM'), _reactionFn) | 157 ..watch(_method('a', 'methodM'), _reactionFn) |
| 161 ..watch(_method('a', 'methodN'), _reactionFn) | 158 ..watch(_method('a', 'methodN'), _reactionFn) |
| 162 ..watch(_method('a', 'methodO'), _reactionFn) | 159 ..watch(_method('a', 'methodO'), _reactionFn) |
| 163 ..watch(_method('a', 'methodP'), _reactionFn) | 160 ..watch(_method('a', 'methodP'), _reactionFn) |
| 164 ..watch(_method('a', 'methodQ'), _reactionFn) | 161 ..watch(_method('a', 'methodQ'), _reactionFn) |
| 165 ..watch(_method('a', 'methodR'), _reactionFn) | 162 ..watch(_method('a', 'methodR'), _reactionFn) |
| 166 ..watch(_method('a', 'methodS'), _reactionFn) | 163 ..watch(_method('a', 'methodS'), _reactionFn) |
| 167 ..watch(_method('a', 'methodT'), _reactionFn); | 164 ..watch(_method('a', 'methodT'), _reactionFn); |
| 168 | 165 |
| 169 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); | 166 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); |
| 170 time('obj.method?()', () => watchGrp.detectChanges()); | 167 time('obj.method?()', () => watchGrp.detectChanges()); |
| 171 } | 168 } |
| 172 | 169 |
| 173 _methodInvoke1() { | 170 _methodInvoke1() { |
| 174 var context = new _Obj(); | 171 var context = new _Obj(); |
| 175 context.a = new _Obj(); | 172 context.a = new _Obj(); |
| 176 var watchGrp = new RootWatchGroup(_dynamicFieldGetterFactory, | 173 var watchGrp = new RootWatchGroup( |
| 177 new DirtyCheckingChangeDetector(_dynamicFieldGetterFactory), context) | 174 new DirtyCheckingChangeDetector(_getterCache), context) |
| 178 ..watch(_method('a', 'methodA1', [_parse('a')]), _reactionFn) | 175 ..watch(_method('a', 'methodA1', [_parse('a')]), _reactionFn) |
| 179 ..watch(_method('a', 'methodB1', [_parse('a')]), _reactionFn) | 176 ..watch(_method('a', 'methodB1', [_parse('a')]), _reactionFn) |
| 180 ..watch(_method('a', 'methodC1', [_parse('a')]), _reactionFn) | 177 ..watch(_method('a', 'methodC1', [_parse('a')]), _reactionFn) |
| 181 ..watch(_method('a', 'methodD1', [_parse('a')]), _reactionFn) | 178 ..watch(_method('a', 'methodD1', [_parse('a')]), _reactionFn) |
| 182 ..watch(_method('a', 'methodE1', [_parse('a')]), _reactionFn) | 179 ..watch(_method('a', 'methodE1', [_parse('a')]), _reactionFn) |
| 183 ..watch(_method('a', 'methodF1', [_parse('a')]), _reactionFn) | 180 ..watch(_method('a', 'methodF1', [_parse('a')]), _reactionFn) |
| 184 ..watch(_method('a', 'methodG1', [_parse('a')]), _reactionFn) | 181 ..watch(_method('a', 'methodG1', [_parse('a')]), _reactionFn) |
| 185 ..watch(_method('a', 'methodH1', [_parse('a')]), _reactionFn) | 182 ..watch(_method('a', 'methodH1', [_parse('a')]), _reactionFn) |
| 186 ..watch(_method('a', 'methodI1', [_parse('a')]), _reactionFn) | 183 ..watch(_method('a', 'methodI1', [_parse('a')]), _reactionFn) |
| 187 ..watch(_method('a', 'methodJ1', [_parse('a')]), _reactionFn) | 184 ..watch(_method('a', 'methodJ1', [_parse('a')]), _reactionFn) |
| 188 ..watch(_method('a', 'methodK1', [_parse('a')]), _reactionFn) | 185 ..watch(_method('a', 'methodK1', [_parse('a')]), _reactionFn) |
| 189 ..watch(_method('a', 'methodL1', [_parse('a')]), _reactionFn) | 186 ..watch(_method('a', 'methodL1', [_parse('a')]), _reactionFn) |
| 190 ..watch(_method('a', 'methodM1', [_parse('a')]), _reactionFn) | 187 ..watch(_method('a', 'methodM1', [_parse('a')]), _reactionFn) |
| 191 ..watch(_method('a', 'methodN1', [_parse('a')]), _reactionFn) | 188 ..watch(_method('a', 'methodN1', [_parse('a')]), _reactionFn) |
| 192 ..watch(_method('a', 'methodO1', [_parse('a')]), _reactionFn) | 189 ..watch(_method('a', 'methodO1', [_parse('a')]), _reactionFn) |
| 193 ..watch(_method('a', 'methodP1', [_parse('a')]), _reactionFn) | 190 ..watch(_method('a', 'methodP1', [_parse('a')]), _reactionFn) |
| 194 ..watch(_method('a', 'methodQ1', [_parse('a')]), _reactionFn) | 191 ..watch(_method('a', 'methodQ1', [_parse('a')]), _reactionFn) |
| 195 ..watch(_method('a', 'methodR1', [_parse('a')]), _reactionFn) | 192 ..watch(_method('a', 'methodR1', [_parse('a')]), _reactionFn) |
| 196 ..watch(_method('a', 'methodS1', [_parse('a')]), _reactionFn) | 193 ..watch(_method('a', 'methodS1', [_parse('a')]), _reactionFn) |
| 197 ..watch(_method('a', 'methodT1', [_parse('a')]), _reactionFn); | 194 ..watch(_method('a', 'methodT1', [_parse('a')]), _reactionFn); |
| 198 | 195 |
| 199 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); | 196 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); |
| 200 time('obj.method?(obj)', () => watchGrp.detectChanges()); | 197 time('obj.method?(obj)', () => watchGrp.detectChanges()); |
| 201 } | 198 } |
| 202 | 199 |
| 203 _function2() { | 200 _function2() { |
| 204 var context = new _Obj(); | 201 var context = new _Obj(); |
| 205 var watchGrp = new RootWatchGroup(_dynamicFieldGetterFactory, | 202 var watchGrp = new RootWatchGroup( |
| 206 new DirtyCheckingChangeDetector(_dynamicFieldGetterFactory), context) | 203 new DirtyCheckingChangeDetector(_getterCache), context) |
| 207 ..watch(_add(0, _parse('a'), _parse('a')), _reactionFn) | 204 ..watch(_add(0, _parse('a'), _parse('a')), _reactionFn) |
| 208 ..watch(_add(1, _parse('a'), _parse('a')), _reactionFn) | 205 ..watch(_add(1, _parse('a'), _parse('a')), _reactionFn) |
| 209 ..watch(_add(2, _parse('a'), _parse('a')), _reactionFn) | 206 ..watch(_add(2, _parse('a'), _parse('a')), _reactionFn) |
| 210 ..watch(_add(3, _parse('a'), _parse('a')), _reactionFn) | 207 ..watch(_add(3, _parse('a'), _parse('a')), _reactionFn) |
| 211 ..watch(_add(4, _parse('a'), _parse('a')), _reactionFn) | 208 ..watch(_add(4, _parse('a'), _parse('a')), _reactionFn) |
| 212 ..watch(_add(5, _parse('a'), _parse('a')), _reactionFn) | 209 ..watch(_add(5, _parse('a'), _parse('a')), _reactionFn) |
| 213 ..watch(_add(6, _parse('a'), _parse('a')), _reactionFn) | 210 ..watch(_add(6, _parse('a'), _parse('a')), _reactionFn) |
| 214 ..watch(_add(7, _parse('a'), _parse('a')), _reactionFn) | 211 ..watch(_add(7, _parse('a'), _parse('a')), _reactionFn) |
| 215 ..watch(_add(8, _parse('a'), _parse('a')), _reactionFn) | 212 ..watch(_add(8, _parse('a'), _parse('a')), _reactionFn) |
| 216 ..watch(_add(9, _parse('a'), _parse('a')), _reactionFn) | 213 ..watch(_add(9, _parse('a'), _parse('a')), _reactionFn) |
| 217 ..watch(_add(10, _parse('a'), _parse('a')), _reactionFn) | 214 ..watch(_add(10, _parse('a'), _parse('a')), _reactionFn) |
| 218 ..watch(_add(11, _parse('a'), _parse('a')), _reactionFn) | 215 ..watch(_add(11, _parse('a'), _parse('a')), _reactionFn) |
| 219 ..watch(_add(12, _parse('a'), _parse('a')), _reactionFn) | 216 ..watch(_add(12, _parse('a'), _parse('a')), _reactionFn) |
| 220 ..watch(_add(13, _parse('a'), _parse('a')), _reactionFn) | 217 ..watch(_add(13, _parse('a'), _parse('a')), _reactionFn) |
| 221 ..watch(_add(14, _parse('a'), _parse('a')), _reactionFn) | 218 ..watch(_add(14, _parse('a'), _parse('a')), _reactionFn) |
| 222 ..watch(_add(15, _parse('a'), _parse('a')), _reactionFn) | 219 ..watch(_add(15, _parse('a'), _parse('a')), _reactionFn) |
| 223 ..watch(_add(16, _parse('a'), _parse('a')), _reactionFn) | 220 ..watch(_add(16, _parse('a'), _parse('a')), _reactionFn) |
| 224 ..watch(_add(17, _parse('a'), _parse('a')), _reactionFn) | 221 ..watch(_add(17, _parse('a'), _parse('a')), _reactionFn) |
| 225 ..watch(_add(18, _parse('a'), _parse('a')), _reactionFn) | 222 ..watch(_add(18, _parse('a'), _parse('a')), _reactionFn) |
| 226 ..watch(_add(19, _parse('a'), _parse('a')), _reactionFn); | 223 ..watch(_add(19, _parse('a'), _parse('a')), _reactionFn); |
| 227 | 224 |
| 228 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); | 225 print('Watch: ${watchGrp.fieldCost}; eval: ${watchGrp.evalCost}'); |
| 229 time('add?(a, a)', () => watchGrp.detectChanges()); | 226 time('add?(a, a)', () => watchGrp.detectChanges()); |
| 230 } | 227 } |
| 231 | 228 |
| 232 AST _add(id, lhs, rhs) => | 229 AST _add(id, lhs, rhs) => |
| 233 new PureFunctionAST('add$id', (a, b) => a + b, [lhs, rhs]); | 230 new PureFunctionAST('add$id', (a, b) => a + b, [lhs, rhs]); |
| 234 | 231 |
| 235 AST _method(lhs, methodName, [args, namedArgs]) { | 232 AST _method(lhs, methodName, [args]) { |
| 236 if (args == null) args = const []; | 233 if (args == null) args = []; |
| 237 if (namedArgs == null) namedArgs = const {}; | 234 return new MethodAST(_parse(lhs), methodName, args); |
| 238 return new MethodAST(_parse(lhs), methodName, args, namedArgs); | |
| 239 } | 235 } |
| 240 | 236 |
| 241 AST _parse(String expression) { | 237 AST _parse(String expression) { |
| 242 var currentAST = new ContextReferenceAST(); | 238 var currentAST = new ContextReferenceAST(); |
| 243 expression.split('.').forEach((name) { | 239 expression.split('.').forEach((name) { |
| 244 currentAST = new FieldReadAST(currentAST, name); | 240 currentAST = new FieldReadAST(currentAST, name); |
| 245 }); | 241 }); |
| 246 return currentAST; | 242 return currentAST; |
| 247 } | 243 } |
| 248 | 244 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 methodM() => m; | 304 methodM() => m; |
| 309 methodN() => n; | 305 methodN() => n; |
| 310 methodO() => o; | 306 methodO() => o; |
| 311 methodP() => p; | 307 methodP() => p; |
| 312 methodQ() => q; | 308 methodQ() => q; |
| 313 methodR() => r; | 309 methodR() => r; |
| 314 methodS() => s; | 310 methodS() => s; |
| 315 methodT() => t; | 311 methodT() => t; |
| 316 | 312 |
| 317 } | 313 } |
| OLD | NEW |