console-profiler

1.1.1 • Public • Published

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

Package Sidebar

Install

npm i console-profiler

Weekly Downloads

85

Version

1.1.1

License

MIT

Unpacked Size

4.08 kB

Total Files

4

Last publish

Collaborators

  • nlapshin