Skip to content

Instantly share code, notes, and snippets.

@bovan
Created November 26, 2010 01:16
Show Gist options
  • Save bovan/716151 to your computer and use it in GitHub Desktop.
Save bovan/716151 to your computer and use it in GitHub Desktop.
testing some if speeds
var time1 = new Date().getTime();
var test = false;
for(var i = 0; i < 100000;i++)
{
if(test) {
test = false;
} else {
test = true;
}
}
var time2 = new Date().getTime();
console.log(time2-time1);
var time3 = new Date().getTime();
var test = false;
for(var i = 0; i < 100000;i++)
{
test = (test) ? false : true;
}
var time4 = new Date().getTime();
console.log(time4-time3);
@bovan
Copy link
Author

bovan commented Nov 26, 2010

Chrome 7 = 100-115
Firefox 3.6 = ~95
IE8 = 45-50

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment