Created
April 8, 2018 05:41
-
-
Save tulik/90893bb726e04da238f1e8589cc97a13 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
'use strict'; | |
function run(callback) { | |
main(bench, v8_mute, callback); | |
main(bench, if_func_1, callback); | |
main(bench, if_func_2, callback); | |
main(bench, if_func_3, callback); | |
} | |
function main(bench, func) { | |
console.time(); | |
bench(func); | |
console.timeEnd(); | |
} | |
function bench(func) { | |
let i; | |
for (i = 2147483647; -2147483648 !== i ; i--) { | |
func(i); | |
} | |
return; | |
} | |
function v8_mute(i) { | |
return; | |
} | |
function if_func_1(i) { | |
if (0 === i) { | |
return; | |
} | |
if (1 === i) { | |
return; | |
} | |
if (2 === i) { | |
return; | |
} | |
if (3 === i) { | |
return; | |
} | |
return; | |
} | |
function if_func_2(i) { | |
if (0 === i) { | |
return; | |
} else if (1 === i) { | |
return; | |
} else if (2 === i) { | |
return; | |
} else if (3 === i) { | |
return; | |
} | |
return; | |
} | |
function if_func_3(i) { | |
if (0 === i || 1 === i || 2 === i || 3 === i) { | |
return; | |
} | |
return; | |
} | |
run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment