time-profile
v2.0.0
Published
Measuring execution time of functions
Downloads
89
Readme
time-profile
Measuring execution time of functions
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