1.0.6 • Published 18 days ago

@node-cli/perf v1.0.6

Weekly downloads
-
License
MIT
Repository
-
Last release
18 days ago

Node CLI perf package

npm

Performance tools for nodejs command-line applications.

Performance

The class Performance is a wrapper around nodejs Performance measurement APIs.

It is intended for an extremely simple case:

  • start performance monitoring
  • do something that takes a while
  • stop performance monitoring
  • read how much time passed between start and stop (in milliseconds)
  • rinse and repeat

Methods

MethodDescription
startStarts measuring performance
stopStops measuring performance and store the result
GetterTypeDescription
resultsObject
results.durationNumberTime in milliseconds

Examples

Basic performance gathering

import { Performance } from "@node-cli/perf;
const perf = new Performance();

// Somewhere in your code, you want to start measuring performance:
perf.start();
// Do long lasting actions
(...)
// When done, tell performance to stop:
perf.stop();
// The duration can now be found in the Performance class getter `results`:
console.log(`It took ${perf.results.duration} milliseconds to run...`);

Multiple performance gatherings

import { Performance } from "@node-cli/perf;
const perf = new Performance();

// Somewhere in your code, you want to start measuring performance:
perf.start();
// Do long lasting actions
(...)
// When done, tell performance to stop:
perf.stop();
// Save the results
const res1 = perf.results.duration;

// Further down in your code, start measuring another performance:
perf.start();
// Do other long lasting actions
(...)
// When done, tell performance to stop:
perf.stop();
// Save the results
const res2 = perf.results.duration;

// -> res1 and res2 will have 2 different duration results.

License

MIT © Arno Versini

1.0.6

18 days ago

1.0.5

2 months ago

1.0.4

3 months ago

1.0.3

10 months ago

1.0.2

11 months ago

1.0.1

12 months ago

1.0.0

12 months ago