Member-only story

Log execution time with Javascript console function

--

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

--

--

Vinodh Thangavel
Vinodh Thangavel

Written by Vinodh Thangavel

Passionate lifelong learner, coding enthusiast, and dedicated mentor. My journey in tech is driven by curiosity, creativity, and a love for sharing knowledge.

No responses yet