var bench = require('bench-utils');
// Counter
var counter = new bench.Counter('loopCounter');
counter.start();
for (var i = 0; i < 100; ++i) {
counter.incr();
}
counter.stop();
// Stopwatch
var stopwatch = new bench.Stopwatch('loopDuration');
stopwatch.start();
for (var i = 0; i < 100; ++i)
;
stopwatch.stop();
// Timestampable
var timestampable = new bench.Timestampable('rpcN');
timestampable.timestamp('received');
timestampable.timestamp('processed');
timestampable.timestamp('replied');
bench.print();
Output:
[C loopCounter value=100 elapsed=0.102041ms]
[S loopDuration cycles=1 elapsed=0.056351ms]
[T rpcN received=0ms processed=0.02386ms replied=0.028968ms]
Use the instances collection to ease your application from passing them around.
bench.counters.loopCounter.incr();
bench.counters['loopCounter'].incr();
Output the matched instances toString
to console.
Default value is 1.
Use start
/stop
in case you want to record how long the counter is
couting. decr
/incr
still works even start is not called.
The stopwatch has cumulative elapsed time from each start
/stop
cycle.
The output list time differences from each event to the first one.