-
Notifications
You must be signed in to change notification settings - Fork 0
JavaScript Performance For Madmen
kevingadd edited this page Jul 10, 2012
·
58 revisions
JavaScript performance is terrifying and unpredictable. If you want things to run fast, you'll need a dowsing rod, but these test cases might help:
- Object.defineProperty versus regular property assignment
- Performance hit for initializing properties in different orders in your constructor (Hidden Classes)
- Deeply nested prototype chains
- String concatenation versus array.join
- Truncating numbers
- Object.create vs new
- Functions containing try/finally are run by the interpreter.
- See http://www.youtube.com/watch?v=XAqIpGU8ZZk for various tips
- Floating-point values are almost universally stored in the heap by V8 (which means each one is an allocation).
- Any function containing a try/catch or try/finally is not optimized.
- Functions that are too long (including comments and newlines/whitespace) are not inlined and may not be optimized.