JavaScript/jQuery简单基准测试

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了JavaScript/jQuery简单基准测试相关的知识,希望对你有一定的参考价值。

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>

以上是关于JavaScript/jQuery简单基准测试的主要内容,如果未能解决你的问题,请参考以下文章