instruments
v0.0.1
Published
Instruments ===============================================================================
Downloads
14
Readme
Instruments
Simple function instrumentation
Installation
Clone this repository:
$ git clone [email protected]:rjz/instruments.git
Usage
Use instruments to create function reporting:
var instruments = require('instruments')();
function somethingSlow (callback) {
setTimeout(callback, 5000);
}
var timedSomethingSlow = instruments.timed('timer1', somethingSlow);
Specify a custom reporter (Defaults to console.log
) when creating the
instruments:
var instruments = require('instruments')({
report: function (entry) {
console.log('[instrument]', entry);
}
});
Instruments
counter(name, fn)
- increment a counter on each calltimed(name, fn)
- elapsed time for an async (continuation-style) functiontimedSync(name, fn)
- elapsed time for a blocking function
Testing
Lint:
$ npm lint
Lint and run test suite:
$ npm test
License
MIT