need
I want to record the elapsed time of an operation in JS
analyze
A timer can be started
console.time(name:string)
to track how long an operation takes. Each timer must have a unique name, and a page can have up to 10,000 timers running at the same time.
When calling console.timeEnd() with this timer name as a parameter, the browser will output the elapsed time of the corresponding timer in milliseconds.
the code
console.time('a');
for (let index = 0; index < 500; index++) {
let a;
a = index;
}
console.timeEnd('a')