0.0.3 • Published 8 years ago
exec-stopwatch v0.0.3
exec-stopwatch
Simple stopwatch for execution time measurement.
Installation
$ npm install exec-stopwatchUsage
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());Examples
You can find examples here
Options
You can pass options object to Stopwatch constructor with follow fields:
formatter(time)— function for transformingtimebefore returning fromgetLapsTimeandgetElapsedTimefunctions.
Methods
.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.