Nobody Pays (for) Magazines
Learn about our RFC process, Open RFC meetings & more.Join in the discussion! »

execution-time

1.4.1 • Public • Published

execution-time

Build Status

NPM

node.js utility to measure execution time in code

Install

npm install execution-time --save

Usage

const perf = require('execution-time')();

//at beginning of your code
perf.start();

//at end of your code
const results = perf.stop();
console.log(results.time);  // in milliseconds

Named performance measurer

const perf = require('execution-time')();

//at beginning of your code, pass any name
perf.start('apiCall');

//at end of your code, pass the same name (anywhere in your flow)
const results = perf.stop('apiCall');
console.log(results.time);  // in milliseconds
console.log(results.preciseWords);  // in words


if you dont care about results but just want to print results

sample usage with debug

const debug = require('debug')('your-module');
const perf = require('execution-time')(debug);

//at beginning of your code
perf.start();

//at end of your code
perf.stop();

also works with console.log/info/warn

const perf = require('execution-time')(console.log);

//at beginning of your code
perf.start();

//at end of your code
perf.stop();

Install

npm i execution-time

DownloadsWeekly Downloads

19,510

Version

1.4.1

License

ISC

Unpacked Size

17.9 kB

Total Files

10

Last publish

Collaborators

  • avatar