// Counter
var counter = new bench.Counter('forLoopCounter');
counter.start();
for (var i = 0; i < 100; ++i) {
counter.incr();
}
counter.stop();
console.log(counter.toString());
// Stopwatch
var stopwatch = new bench.Stopwatch('forLoopDuration');
stopwatch.start();
for (var i = 0; i < 100; ++i)
;
stopwatch.stop();
console.log(stopwatch.toString());
// Timestampable
var rpc = new bench.Timestampable('rpc');
rpc.timestamp('received');
rpc.timestamp('processed');
rpc.timestamp('replied');
console.log(rpc.toString());
Use the instances collection to ease your application from passing them around.
bench.counters.forLoopCounter.incr();
bench.counters['forLoopCounter'].incr();
Default value is 1.
Use start/stop in case you also want to know how long the counter is couting.
It is cumulative elapsed time from each start/stop cycle.
The output will be like:
[timestampable rpc received=0ms processed=0.010993ms replied=0.013843ms]
Which the first event will always be 0ms, following events will have time difference from the first event.