Skip to content

Instantly share code, notes, and snippets.

@jacobwise
Last active December 12, 2017 16:57
Show Gist options
  • Save jacobwise/931dfe470c4f01422dd5c99cb0574816 to your computer and use it in GitHub Desktop.
Save jacobwise/931dfe470c4f01422dd5c99cb0574816 to your computer and use it in GitHub Desktop.
var tests = 1000;
var i = 0;
var t0 = performance.now();
while (i < tests) {
functionOne()
i++;
}
var t1 = performance.now();
console.log("Call to test 1 took " + (t1 - t0) + " milliseconds.");
var j = 0;
var t0 = performance.now();
while (j < tests) {
functionTwo()
j++;
}
var t1 = performance.now();
console.log("Call to test 2 took " + (t1 - t0) + " milliseconds.");
function functioOne() {
return true
}
function functionTwo() {
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment