exec-stopwatch
v0.0.3
Published
Simple stopwatch for execution time measurement
Downloads
3
Maintainers
Readme
exec-stopwatch
Simple stopwatch for execution time measurement.
Installation
$ npm install exec-stopwatch
Usage
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 transformingtime
before returning fromgetLapsTime
andgetElapsedTime
functions.
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 ofstart
method call untilstop
method call.