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

相关文章:

  • 2021-07-29
  • 2021-10-21
  • 2021-12-15
  • 2021-12-15
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-12-15
  • 2021-06-18
  • 2022-12-23
  • 2021-11-13
  • 2022-03-08
相关资源
相似解决方案