Skip to content

Instantly share code, notes, and snippets.

@peterwmwong
Created January 11, 2018 04:14
Show Gist options
  • Save peterwmwong/bc1b6bd56f613134b5bfb2d2962c39ae to your computer and use it in GitHub Desktop.
Save peterwmwong/bc1b6bd56f613134b5bfb2d2962c39ae to your computer and use it in GitHub Desktop.
// Setup
const foo = [];
for (let i = 0; i < 10000000; i++) foo.push([8, null], [8, 99]);
const start = performance.now();
// Bench
for (const c of foo) Math.max(c[0], c[1] || 0);
const end = performance.now();
console.log((end - start).toFixed(2), 'ms');
> for i in {0..5}; do /p/google3/v8/out.gn/x64.release/d8 test.js; done
231.06 ms
222.25 ms
222.82 ms
231.02 ms
228.40 ms
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment