Super Simple execution tracking for Javascript and Node.js
Gabriele Formenti
Posted on June 8, 2020
Sometimes you need to measure time execution of a script or part of it, simple answer could be call the Date() function many times and compute elapsed time.
Recently I found out a better method that works for javascript and Node.js too, the console.time.
This function comes from Web API and have a great support:
Using it is very simple:
//start timer with name "My Timer Name"
console.time("My Timer Name");
alert("Click to continue");
//log time without sotp the timer
console.timeLog("My Timer Name");
//My Timer Name: 1898.589111328125ms
alert("Click to continue again...");
//log time and stop timer
console.timeEnd("My Timer Name");
//My Timer Name: 2641.26123046875ms
For more information you can read official docs on MDN
Cover Image: Ansgar Koreng
💖 💪 🙅 🚩
Gabriele Formenti
Posted on June 8, 2020
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.