function add(){ //这里放要执行的代码 } //开始测试并输出 function test() { var start=new Date().getTime(); add(); var end=new Date().getTime(); return (end-start)+"ms"; } var time=test(add); alert(time);
js代码如何测试代码运行时间
原文:http://www.cnblogs.com/275147378abc/p/5227205.html