Simple stopwatch for execution time measurement.
$ npm install exec-stopwatch
var Stopwatch = require('exec-stopwatch');
var stopwatch = new Stopwatch();
stopwatch.start();
syncFunction();
stopwatch.lap();
syncFunction();
stopwatch.lap();
syncFunction();
stopwatch.lap();
stopwatch.stop();
console.log(stopwatch.getLapsTime());
console.log(stopwatch.getElapsedTime());You can find examples here
You can pass options object to Stopwatch constructor with follow fields:
formatter(time)— function for transformingtimebefore returning fromgetLapsTimeandgetElapsedTimefunctions.
.start()— runs stopwatch;.lap()— saves elapsed time of current lap. Returns this time in nanoseconds;.stop()— stops stopwatch;.getLapsTime()— returns times for each lap;.getElapsedTime()— returns time, elapsed from the moment ofstartmethod call untilstopmethod call.