Skip to content

Measure function execution time in Node JS

This quick post describes how to log the execution time of a JavaScript function. The console object has two methods – time() and timeEnd() that help with analysing performance of your JavaScript / Node Js code. It also helps you log the time taken by a function.


Call console.time() with an argument. This starts a timer. The argument you pass is a unique string which needs to be passed to console.timeEnd() to stop the timer. At a point of time, there can be 10000 timers running in parallel.


console.timeLog() prints time taken from the point the timer is started.


This method tops a timer that was previously started by calling console.time()


One thing to note here is timeEnd() method outputs the time taken in milliseconds.

alert("Click to start");
for (let i = 0; i < 5000-; i++) {
  // Your code here
See also  Different ways to check if an Object is empty using JavaScript

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.