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:
console.time('someFunction')someFunction() // Whatever is timed goes between the two "console.time"console.timeEnd('someFunction')
注意 :
传递给
time()和
timeEnd()方法的字符串必须匹配(以 使计时器按预期完成)。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)