Web探索|Asp.net||Jquery|MVC

Web前沿技术、移动解决方案
  博客园  :: 首页  :: 新随笔  :: 管理

简易计算JS运行用时

Posted on 2013-03-10 21:13  reckcn  阅读(198)  评论(0编辑  收藏  举报
var runtime = {
    start : function() {
        this.startTime = new Date();
    },
    end : function() {
        return (new Date() - this.startTime);
    }
};
runtime.start();
var html = '';
for (var i=0; i<1000; i++) {
    html += i+'cxcxcxcxcxcxcxc<br />';
}
document.body.innerHTML += html;
alert(runtime.end()); //单位ms