Member-only story
Log execution time with Javascript console function
Jun 19, 2023
Console are now much more powerful than just displaying a text with console.log
Steps for logging execution time
- console.time() — will start the timer
- console.timeEnd() — will stop the timer and log the time taken from execution of console.time to console.timeEnd functions
Running multiple timers in parallel
We can optionally send the label arguments to these console functions so that we can have multiple named timers
console.time('first');
//....some logics
console.time('last');
//....some logics
console.timeEnd('last');//displays last timer execution time as last: X ms
//...some logics
console.timeEnd('first');//displays first timer execution time as last: X ms