Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

performance-time-tracker

sumitLKpatel86MIT1.0.6

A Node.js package for performance time tracking of functions or scripts

nodejs, performance now, performance, performance monitor, execution time, time tracker, function timing, function timing monitoring, benchmark, profiling, code profiling, performance analysis, runtime measurement, execution tracking, node performance, async timing, measure function time, function performance, performance testing, node utility, lightweight monitoring, tracking, debugger

readme

Execution Time Measurement for Node.js Functions

A simple and lightweight Node.js utility to measure the execution time of your functions or code blocks. Ideal for benchmarking, profiling, or just keeping an eye on performance.

MIT License Node.js Version PRs Welcome

Features

  • Measure the execution time of individual functions
  • Easy to integrate into existing Node.js projects
  • Lightweight and efficient
  • Provides accurate timing information
  • Suitable for performance monitoring and analysis

Installation

You can install the package using npm:

npm install performance-time-tracker --save

Usage

const {startMonitoring, stopMonitoring} = require('performance-time-tracker');

// Start monitoring a function
startMonitoring('myFunction');

// Call your function here

// Stop monitoring the function
stopMonitoring();

OR

const {track} = require('performance-time-tracker');

const wrappedAsyncFunction = track('myFunction', asyncFunction);

await wrappedAsyncFunction();

To measure how long a function or code block takes to run, wrap it between startMonitoring(label) and stopMonitoring().

The label is a name you give the block you're monitoring—this helps identify it in the output.

You can use this for both synchronous and asynchronous functions.

Example

const {startMonitoring, stopMonitoring} = require('performance-time-tracker');

const asyncFunction = () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve('Response after 3 seconds');
        }, 3000);
    });
};

startMonitoring('myFunction'); //give lable (in string) of your function so you can identify

    await asyncFunction();

stopMonitoring();


//result
//Execution started for function "myFunction".
//[1] [myFunction] - Execution Time:     3000.00 ms

OR

const {track} = require('performance-time-tracker');

const asyncFunction = () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve('Response after 3 seconds');
        }, 3000);
    });
};

const wrappedAsyncFunction = track('myFunction', asyncFunction);

await wrappedAsyncFunction();


//result
//Execution started for function "myFunction".
//[1] [myFunction] - Execution Time:     3000.00 ms

You can monitor multiple functions sequentially:

const {startMonitoring, stopMonitoring} = require('performance-time-tracker');

const asyncFunction = () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve('Response after 3 seconds');
        }, 3000);
    });
};

startMonitoring('myFunction'); //give lable (in string) of your function so you can identify
    await asyncFunction();
stopMonitoring();


const asyncFunction2 = () => {
    return new Promise((resolve) => {
        setTimeout(() => {
            resolve('Response after 2.5 seconds');
        }, 2500);
    });
};

startMonitoring('response time of myFunction2'); //give lable (in string) of your function so you can identify
    await asyncFunction2();
stopMonitoring();


//result
//Execution started for "myFunction".
//[1] [myFunction] - Execution Time:     3000.00 ms
//Execution started for "response time of myFunction2".
//[2] [response time of myFunction2] - Execution Time:     2500.00 ms

License

performance-time-tracker is released under the MIT License. Copyright (c) 2025 @sumitLKpatel