Created
January 11, 2017 23:44
-
-
Save waiteb3/eeff151dd7f1242fb3fe75acb3bddf04 to your computer and use it in GitHub Desktop.
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 name1() { | |
return 1 | |
} | |
const name2 = new Function(`return function name2() { | |
return 1 | |
}`)() | |
let start1 = 0, end1 = 0; | |
let start2 = 0, end2 = 0; | |
for (let i = 0; i < 9999; i++) { | |
console.error(name1()) | |
console.error(name2()) | |
} | |
start1 = Date.now() | |
for (let i1 = 0; i1 < 9999; i1++) { | |
console.error(name1()) | |
} | |
end1 = Date.now() | |
start2 = Date.now() | |
for (let i2 = 0; i2 < 9999; i2++) { | |
console.error(name2()) | |
} | |
end2 = Date.now() | |
console.log(end1 - start1, 'ms') | |
console.log(end2 - start2, 'ms') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment