time-profile

Measuring execution time of functions

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
time-profile
1602.0.05 years ago5 years agoMinified + gzip package size for time-profile in KB

Readme

time-profile
Measuring execution time of functions
!NPM versionnpm-imagenpm-url !build statustravis-imagetravis-url !Test coveragecodecov-imagecodecov-url !David depsdavid-imagedavid-url !Known Vulnerabilitiessnyk-imagesnyk-url !npm downloaddownload-imagedownload-url
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