- 统计两个时刻的过程d1
performance.mark('start1');
setTimeout(()=>{
performance.mark('end1')
performance.measure('d1', 'start1', 'end1')
console.log(performance.getEntriesByName('d1')[0]);
},1000)
- 统计多个过程d1
function sta(){
performance.mark('start1');
setTimeout(()=>{
performance.mark('end1')
performance.measure('d1', 'start1', 'end1')
},1000)
}
let count = 10;
setInterval(()=>{
if(count>0){
sta();
count--;
}else{
performance.getEntriesByName('d1');
}
},2000);