您的代码有多快?
你想知道一段代码执行需要多长时间吗?那么你来对地方了。你可以简单地用console.time
函数 包装你的代码块,来测量代码的执行时间。
console.time("Label A")
let num = -999999
for(let i = 0; i < 99999; i++){
num++
}
console.log(num)
console.timeEnd("Label A")
文章来源:https://dev.to/0shuvo0/how-fast-is-your-code-31ji请务必查看我的其他文章