Created
July 5, 2012 16:35
-
-
Save sudar/3054695 to your computer and use it in GitHub Desktop.
Improve JavaScript performance in V8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = new Array(); | |
for (var b = 0; b < 10; b++) { | |
a[0] |= b; | |
} | |
a = new Array(); | |
a[0] = 0; // just this change alone make code 2x faster | |
for (var b = 0; b < 10; b++) { | |
a[0] |= b; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Point(x,y) { | |
this.x = x; | |
this.y - y; | |
} | |
var p1 = new Point(11, 22); | |
var p2 = new Point(15, 42); | |
p2.z = 15; // don't do this |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# log names of optimized functions | |
d8 --trace-opt primes.js | |
# logs optimizing compiler bailouts | |
d8 --trace-bailout prmies.js | |
# log functions that v8 had to deoptimize | |
d8 --trace-deopt primes.js | |
# You can also call Chrome with all flags | |
"/Applications/Google Chrome/MacOs/Google Chrome" --js-flags = "--trace-opt --trace-deopt --trace-bailout" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
thank you 👍