Constantin Druccdruc

Hey, I'm Constantin Druc!

I'm a web developer sharing everything I know about building web applications.

Measuring time using console.time

Instead of creating a date object and substracting the current time, use console.time to start a timer.

Give it a label, add checkpoints using console.timeLog, and stop the timer using console.timeEnd

// Yucky, but ok
const start = new Date();
await createUser();
console.log(new Date() - start, "createUser");
await sendEmail();
console.log(new Date() - start, "sendEmail");

// ⭐️
await createUser();
console.timeLog("register", "createUser");
await sendEmail();
console.timeLog("register", "sendEmail");

Way easier to write.