eventloop-latency
This lib is part of Bronitor project. It counts eventloop latency using process.hrtime
Requirements
Code written using ECMAScript 2015. It tested on node >= 4
Use babel if, you want to use it on node < 4
Installation
$ npm i eventloop-latency --production
Usage
const EL = interval = 5000 hrInterval = 10 monitoring = interval hrInterval; monitoringstarttrue; monitoring;monitoring; monitoringstart;
Docs
- monitoring - main object, eventemitter, takes two options:
- iterval - interval in ms for emitting 'data' event, optional, defaults to 5000 ms
- hrIntreval - interval in ms using to count latency, should be in range 10-100, optional, defaults to 10 ms
- start() - function, that start monitoring, takes option:
- enableEmit - if true, monitoring will emit "data" event, else function countLatency() is used to get latency info
- stop() - function, that stop monitoring
- countLatency() - function, that return array with latency
- "data" event - returns array of latency in µs(microseconds, 10e-6 s) during the interval
Examples
You can see small example in demos/server.js. Run it:
$ npm run-script demo
Tests
To run the test suite, first install the dependencies, then run npm test
:
$ npm install$ npm test