DEV Community 👩‍💻👨‍💻

Cover image for How to measure the time javascript function with
Dany Paredes
Dany Paredes

Posted on

How to measure the time javascript function with

Sometimes, we want to know how is the performance or time spend in some function or process, it can be solved using help us to get time in milliseconds, and we can measure the time between some function complete his process.


We can take the current and compare with the same when our function finishes the process, like my example.

function getUsers() {
  let from =;
  setTimeout(() => {
    console.log("Getting users..")
    let to =
    let total = from - to;
    console.log(`Total miliseconds ${total}`); 
// Total miliseconds -3003
Enter fullscreen mode Exit fullscreen mode

If you want to learn more about it please go free to read more in

Top comments (0)

Classic DEV post:

CLI tools you won't be able to live without 🔧

CLI tools