1.1.1 • Published 4 years ago

console-profiler v1.1.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

console-profiler

Simple runtime profiler based on the console module

Installation

npm install --save console-profiler

Usage

  1. Create console instance:
const Console = require('console-profile');
const consoleProfiler = new Console({
    threshold: 1000, // ms
    namespace: "profiler"
});
  1. Use it:
consoleProfile.time('profile');

longRunningFunction();

consoleProfile.timeEnd('profiler');

If function runs longer than threshold, you will see a message in the console, like that:

  profiler profile: 1234.45ms

Options

  • threshold (number): upper threshold. Default = 0(profile disabled).
  • namespace (string): namespace for console message. Default = console:time.
  • fixed (number): number of numbers after the decimal point. Default = 2.
  • test (boolean): disabled console message when testing. Default = false.

License

MIT