Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created April 9, 2010 16:21
Show Gist options
  • Select an option

  • Save subtleGradient/361334 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/361334 to your computer and use it in GitHub Desktop.
var iterations = 999999, control = '', eq_same = '', seq_same = '', eq_diff = '', seq_diff = '', st, en;
setTimeout(function(){
st = +new Date();
for (i = 0; i < iterations; i++);
en = +new Date();
control = en - st;
print();
},100);
setTimeout(function(){
st = +new Date();
for (i = 0; i < iterations; i++)
if (i == 10);
en = +new Date();
eq_same = en - st;
print();
},100);
setTimeout(function(){
st = +new Date();
for (i = 0; i < iterations; i++)
if (i === 10);
en = +new Date();
seq_same = en - st;
print();
},100);
setTimeout(function(){
st = +new Date();
for (i = 0; i < iterations; i++)
if (i == '10');
en = +new Date();
eq_diff = en - st;
print();
},100);
setTimeout(function(){
st = +new Date();
for (i = 0; i < iterations; i++)
if (i === '10');
en = +new Date();
seq_diff = en - st;
print();
},100);
function print(){
document.body.innerHTML =
('Same type: == ' + (eq_same - control) + ', === ' + (seq_same - control)) +
'<br>' +
('Diff type: == ' + (eq_diff - control) + ', === ' + (seq_diff - control));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment