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