2.0.0 • Published 6 years ago

time-profile v2.0.0

Weekly downloads
75
License
MIT
Repository
github
Last release
6 years ago

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
2.0.0

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago