Derp, had parseInt on the brain. Thanks karbassi in 6541eb9d80db42c6ced396fcd198228bf...
[jquery.git] / speed / benchmark.js
1 // Runs a function many times without the function call overhead
2 function benchmark(fn, times){
3         fn = fn.toString();
4         var s = fn.indexOf('{')+1,
5                 e = fn.lastIndexOf('}');
6         fn = fn.substring(s,e);
7         
8         return new Function('i','var t=new Date;while(i--){'+fn+'};return new Date-t')(times);
9 }