measure-duration

0.1.6 • Public • Published

measure-duration

Simple npm package to measure duration of javascript funcion calls, and log information. Supports measuring functions returning Promise or measuring an async functions.

Installation

npm install measure-duration

Usage

let measure = require("measure-duration");

let duration = measure.measureCall(wait, 500); // calling function wait with parameter 500

//To disable logging to console.log or your custom logger
measure.disableLogging(); //Entries will still be logged to internal logging

measure.enableLogging(); //Reenable logging

measure.logger = (msg) => { console.log(msg); } ; //Setting up a custom logger/reporter

duration = measure.measureCall(wait, 400); // calling function wait with parameter 400

measure.report(); //Write all logged entries to measure.logger function, uses console.log by default

// Constains array of logged call,
measure.results
// each in the format of 
// { name: funcionName, duration: callDuration, when: calledWhen };


Package Sidebar

Install

npm i measure-duration

Weekly Downloads

0

Version

0.1.6

License

ISC

Unpacked Size

4.82 kB

Total Files

4

Last publish

Collaborators

  • jonasbr68