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