Skip to content

Instantly share code, notes, and snippets.

@matsumana
Last active February 27, 2021 15:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save matsumana/958d8d61f450658c3cfa93758389c507 to your computer and use it in GitHub Desktop.
Save matsumana/958d8d61f450658c3cfa93758389c507 to your computer and use it in GitHub Desktop.
const f = () => {
const arr = new Array();
for (let i = 0; i < 1000000; i++) {
arr.push((Math.random() * 100) | 0);
}
let sum = 0;
for (let i = 0; i < arr.length; i++) {
const value = arr[i];
sum += value;
}
}
for (let i = 0; i < 9999; i++) f();
// $ time out/x64.release/d8 --print-opt-code --code-comments TestCode1.js > tc1.code
// out/x64.release/d8 --print-opt-code --code-comments TestCode1.js > tc1.code 184.06s user 36.83s system 105% cpu 3:30.02 total
const f = () => {
const arr = new Array();
for (let i = 0; i < 1000000; i++) {
arr.push((Math.random() * 100) | 0);
}
let sum = 0;
for (let i = 0; i < 1000000; i++) {
const value = arr[i];
sum += value;
}
}
for (let i = 0; i < 9999; i++) f();
// $ time out/x64.release/d8 --print-opt-code --code-comments TestCode2.js > tc2.code
// out/x64.release/d8 --print-opt-code --code-comments TestCode2.js > tc2.code 184.69s user 36.32s system 105% cpu 3:30.13 total
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment