Skip to content

Instantly share code, notes, and snippets.

@kyo-ago
Created January 16, 2012 04:43
Show Gist options
  • Save kyo-ago/1619107 to your computer and use it in GitHub Desktop.
Save kyo-ago/1619107 to your computer and use it in GitHub Desktop.
console.time(111);
var a=10000;
var b=document.getElementById.bind(document);
while(a--)b('runner');
console.timeEnd(111);
console.time(222);
var a=10000;
while(a--)document.getElementById('runner');
console.timeEnd(222);
console.time(333);
var a=10000;
var b=function(id){return document.getElementById(id)};
while(a--)b('runner');
console.timeEnd(333);
console.time(444);
var a=10000;
var b=document.getElementById;
while(a--)b.call(document, 'runner');
console.timeEnd(444);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment