js执行时间(调试)

js 执行时间

function use_time(func) {
    var start = new Date().getTime(); console.log(start);
    
    func();

    var end = new Date().getTime(); console.log(end);        
    console.log(end-start+' ms');
}


2. console
console.log(console); _prototype

console.time('time a');
use_time(test);
console.timeEnd('time a');
// 输出 time a: 3.006ms  (更准确)

分析器
console.profile('性能分析器一');
Foo();
console.profileEnd();

js chrome调试
f11       逐句执行语句,遇到调用方法的地方进入到方法内部 step into next funcation call
shift+f11 执行当前的函数,跳出当前执行的函数到调用出  step out of current funcation call
f10       逐句执行语句,遇到调用方法的地方仍然逐句执行,不进入方法内部 stop over next function call 

原文地址:https://www.cnblogs.com/isdom/p/webclips048.html