Last active
August 1, 2016 20:56
Star
You must be signed in to star a gist
Benchmark cache length
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 for1() { | |
'use strict'; | |
const a = []; | |
for (let i = 0; i < 9999999; i++) { | |
a.push(i); | |
} | |
console.time('loop'); | |
for (let c = 0; c < 1e3; c++) { | |
// ... | |
} | |
for (let i = 0, len = a.length; i < len; i++) { | |
// ... | |
} | |
console.timeEnd('loop'); | |
} | |
for1(); |
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 for2() { | |
'use strict'; | |
const a = []; | |
for (let i = 0; i < 9999999; i++) { | |
a.push(i); | |
} | |
console.time('loop'); | |
for (let c = 0; c < 1e3; c++) { | |
// ... | |
} | |
for (let i = 0; i < a.length; i++) { | |
// ... | |
} | |
console.timeEnd('loop'); | |
} | |
for2(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment