Posted By

Piotrek290 on 10/26/09


Tagged

js Stress


Versions (?)

Stress


 / Published in: JavaScript
 

  1. // *** CORE ***
  2. function stress(f){var n=arguments[1]||100,i,t,s=new Date();for(i=0;i<n;++i)f();t=((new Date())-s);return{handler:f,total:t,each:t/n};}
  3.  
  4.  
  5. // *** EXAMPLE ***
  6. // return total time of 100 enforcements function
  7. alert(stress(function(){
  8. var tags = document.getElementsByTagName("*");
  9. for(var i = 0; i < tags.lenght; ++i){
  10. tags[i].innerHTML = i;
  11. }
  12. }).total);

Report this snippet  

You need to login to post a comment.