Scenario
We want to see how many milliseconds it takes to mutate a count
index reference from one to a million.
Approach
Use console.time
.
console.time('count performance');
for (let count = 0; count++; count <= 1000000) {
//Profile how long this takes
}
console.timeEnd('count performance');
This will log.
count performance: 0.005126953125 ms
Demo
Note that the Stackblitz console on the right hand side currently does not show console.time
, so to see the result open the Developer Tools in your browser and click on the console.