Skip to content

Instantly share code, notes, and snippets.

@sudar
Created July 5, 2012 16:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sudar/3054695 to your computer and use it in GitHub Desktop.
Save sudar/3054695 to your computer and use it in GitHub Desktop.
Improve JavaScript performance in V8
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;
}
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
# 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"
@kuil09
Copy link

kuil09 commented Aug 27, 2014

thank you 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment