time-profile

2.0.0 • Public • Published

time-profile

Measuring execution time of functions

NPM version build status Test coverage David deps Known Vulnerabilities npm download

A Tool to help you to measure execution time of functions.

Install

$ npm install time-profile

Usage

const timeProfile = require('time-profile');
 
const profiler = timeProfile.getInstance('aProfiler');
 
profiler.start('app launch');
// ... do work
 
profiler.start('load plugins');
// ... load plugins
profiler.end('load plugins');
 
profiler.start('load services');
// ... load services
profiler.end('load services');
 
profiler.start('init');
// ... init
profiler.end('init');
 
// ...
profiler.end('app launch');
 
// in the end, you can dump the profile data to a json
const json = profiler.toJSON(); // [ Entry { name, start, end, duration, pid }, ... ]
 
// also you can print the profile timeline
console.log(profiler.toString('this is timeline:'));
 
// you shoud destroy it when it's not needed anymore
profiler.destroy();
this is timeline:
▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [172ms] - app launch
  ▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇▇  [91ms] - load plugins
   ▇▇▇▇▇▇▇▇▇▇▇▇▇  [47ms] - load services
                 ▇▇▇▇▇▇▇▇▇▇▇  [41ms] - init

Readme

Keywords

Package Sidebar

Install

npm i time-profile

Weekly Downloads

9

Version

2.0.0

License

MIT

Unpacked Size

10.6 kB

Total Files

7

Last publish

Collaborators

  • gxcsoccer