使用 performance.now():
var t0 = performance.now()doSomething() // <---- The function you're measuring time forvar t1 = performance.now()console.log("Call to doSomething took " + (t1 - t0) + " milliseconds.")NodeJs
:需要导入
performance类
使用 console.time: (非标准)(living standard)
console.time('someFunction')someFunction() // Whatever is timed goes between the two "console.time"console.timeEnd('someFunction')注意 :
传递给
time()和
timeEnd()方法的字符串必须匹配(以 使计时器按预期完成)。



