打赏

node js 获取程序执行时间 time timeEnd

node js 获取程序执行时间 time timeEnd

示例代码:

function getFunRunTime(){
    console.time('test');
    let temp;
    for (let index = 0; index < 10000; index++) {
        temp += index
    }
    // time和timeEnd的参数要相同
    console.timeEnd('test');
}
getFunRunTime();

控制台输出:

test: 0.384765625ms
posted @ 2020-01-30 22:44  孟繁贵  阅读(2738)  评论(0编辑  收藏  举报
TOP