-
Notifications
You must be signed in to change notification settings - Fork 27.4k
Conversation
@jbedard thanks for the PR! can you add a benchmark to https://github.com/angular/angular.js/tree/master/benchmarks to prove that these changes are beneficial? |
05ee69e
to
eb47e91
Compare
@btford I've added a new benchpress benchmark for execution of $parse()ed expressions (fd45e8a). It currently has tests for the different types of expressions (property, binary op, filter, ...). Basically it generates data (2000 rows right now), ng-repeats a bunch of expressions (12 per test right now, except object literals that are too slow) and then measures the digest (x50 right now) time. I updated eb47e91 such that the wrapper function is now only needed for one-time binding so $parse()ed properties now benefit form this as well. (A wrapper is needed for one-time because the one-time Here are the numbers (ms) for the current tests in the benchmark (12 expressions x 2000 rows x 50 digests):
|
…ions This allows the parser and lexer objects to get GC-ed once the expression is parsed. Part of #8901
Thanks for looking into all of these and getting them in so fast! And note my comment regarding the changed tests/error-message if you haven't already (can avoid changing the tests/message if we want, see jbedard@cec3344) |
c074181 might be the only one worth merging to allow the Parser/Lexer objects to be GCed.
f4ea3c9 addresses a TODO although I didn't notice any major improvements (even though the removed wrapper method is often ~10% when profiling...). Unfortunately the wrapper method is still needed for the expressions returned from
$parse
, but use ofgetterFn
s within other expressions don't have the wrapper. This also required a minor error message change.f4ea3c9 could be expanded in other ways though. Maybe allowing
$parse
ed methods to return something such as a$$watchFn
property that can be watched instead of the full expression being watched. The simple case would be returning the rawgetterFn
instead of the wrapper for simplefoo.bar
expressions. A more complicated case would be expressions such asmyVar % 2 === 0
returning only themyVar
getterFn
to be watched (and then a special watch delegate to see if the full expression actually changed, which makes it more complicated...). Or only watching the input+args to filters etc. Not sure how common or useful those would be though...The rest are mostly style/simplifying but I thought I'd leave them in there.