let start = performance.now();
let sum = 0;
for (let i = 0; i < 200000; i++) {
for (let i = 0; i < 1; i++) {
sum += Math.random()
}
}
let end = performance.now();
console.log(end - start)
let start = performance.now();
let sum = 0;
for (let i = 0; i < 200000; i++) {
for (let i = 0; i < 1; i++) {
sum += Math.random()
}
}
let end = performance.now();
console.log(end - start)
本文标题:使用 performance 测试代码执行时间
本文链接:https://www.haomeiwen.com/subject/dyifddtx.html
网友评论