et

execution-time

node.js utility to measure execution time in code

Showing:

Popularity

Downloads/wk

23.8K

GitHub Stars

19

Maintenance

Last Commit

1yr ago

Contributors

5

Package

Dependencies

1

Size (min+gzip)

0.8KB

License

ISC

Type Definitions

Tree-Shakeable

No?

Categories

Readme

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();

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100