Posted By

LuckyShot on 04/15/10


Tagged

javascript jquery benchmarking


Versions (?)

Who likes this?

2 people have marked this snippet as a favorite

LuckyShot
larste


JavaScript/jQuery simple benchmarking


 / Published in: PHP
 

URL: http://blog.projekt2k.de/2010/01/benchmarking-jquery-1-4/

Disable Firebug and plugins, close other tabs and close other programs for more accurate results!

  1. function t() {
  2. var time = new Date();
  3. return time.getTime();
  4. }
  5.  
  6.  
  7. $(document).ready(function() {
  8. var s = t();
  9.  
  10. for (var i=0; i<10000; i=i+1) {
  11. $('#content').html("hello");
  12. }
  13.  
  14. $('#out').append( (t()-s) +'ms');
  15. });
  16.  
  17.  
  18.  
  19.  
  20. <div>
  21. <p>Time: <span id="out"></span></p>
  22. </div>
  23.  
  24. <div>
  25. <p>Content: <span id="content"></span></p>
  26. </div>

Report this snippet  

You need to login to post a comment.