1.0.2 • Published 8 years ago

ah-measure-time v1.0.2

Weekly downloads
3
License
ISC
Repository
-
Last release
8 years ago

Measuring average time in node in milli, micro and nano seconds over multiple measures.

Usecase

const Measure = require('ah-measure'); // Takes name and precision [milli, micro, nano] as arguments. milli is default for precision
const dbTime = new Measure('DB operation time', 'micro').start();
db.find({}, function(err, data) {
  dbTime.end(); //outputs DB operation time: [average time] micro seconds
});

API

  • start() Use to start the timer. Returns the instance.
  • end() Use to end the timer. Also adds the time to the total time of all measures done with this instance of Measure. Will also log to the average time to the console. Return the instance.
  • average() Returns the average time of all measures.
  • log() Logs the average time to the console and returns the same string so it can be used for other logging.