DEV Community

Cover image for Super Simple execution tracking for Javascript and Node.js
Gabriele Formenti
Gabriele Formenti

Posted on

4

Super Simple execution tracking for Javascript and Node.js

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:

Alt Text

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
Enter fullscreen mode Exit fullscreen mode

For more information you can read official docs on MDN

Cover Image: Ansgar Koreng

Image of Stellar post

How a Hackathon Win Led to My Startup Getting Funded

In this episode, you'll see:

  • The hackathon wins that sparked the journey.
  • The moment José and Joseph decided to go all-in.
  • Building a working prototype on Stellar.
  • Using the PassKeys feature of Soroban.
  • Getting funded via the Stellar Community Fund.

Watch the video 🎥

Top comments (1)

Collapse
 
chloeveux profile image
chloeveux

Salut, Gabriele! C'est une méthode api intéressante. Et c'est vanille js. Dans d'autres langues, je préfère utiliser le gestionnaire de contexte.

Pourrais-tu m'aider s'il te plaît. J'ai besoin d'un examen de mon #showdev sur dev.to. Merci)

nextjs tutorial video

Youtube Tutorial Series 📺

So you built a Next.js app, but you need a clear view of the entire operation flow to be able to identify performance bottlenecks before you launch. But how do you get started? Get the essentials on tracing for Next.js from @nikolovlazar in this video series 👀

Watch the Youtube series

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay