Skip to content

Instantly share code, notes, and snippets.

@NV
Created June 19, 2010 12:03
Show Gist options
  • Select an option

  • Save NV/444839 to your computer and use it in GitHub Desktop.

Select an option

Save NV/444839 to your computer and use it in GitHub Desktop.
const ITERATIONS = 100000;
(function(){
var start = new Date;
for (var i=0; i<ITERATIONS; ++i) {
Math.floor((i + ITERATIONS) / 2);
}
var end = new Date;
print("Math.floor: "+ (end - start) +"ms");
})();
(function(){
var start = new Date;
for (var i=0; i<ITERATIONS; ++i) {
(i + ITERATIONS) >> 1;
}
var end = new Date;
print("Binary >> : "+ (end - start) +"ms");
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment