{"id":13670716,"url":"https://github.com/korzhev/eventloop-latency","last_synced_at":"2025-04-27T13:32:53.423Z","repository":{"id":57231343,"uuid":"52265902","full_name":"korzhev/eventloop-latency","owner":"korzhev","description":"Counting node.js eventloop latency.","archived":false,"fork":false,"pushed_at":"2016-04-16T13:56:52.000Z","size":19,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-21T08:03:47.222Z","etag":null,"topics":["event-loop","eventloop","latency","node","nodejs"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/korzhev.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-02-22T10:30:53.000Z","updated_at":"2023-11-03T17:12:14.000Z","dependencies_parsed_at":"2022-09-26T16:40:47.269Z","dependency_job_id":null,"html_url":"https://github.com/korzhev/eventloop-latency","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korzhev%2Feventloop-latency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korzhev%2Feventloop-latency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korzhev%2Feventloop-latency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/korzhev%2Feventloop-latency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/korzhev","download_url":"https://codeload.github.com/korzhev/eventloop-latency/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251145692,"owners_count":21543082,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event-loop","eventloop","latency","node","nodejs"],"created_at":"2024-08-02T09:00:48.422Z","updated_at":"2025-04-27T13:32:48.414Z","avatar_url":"https://github.com/korzhev.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"# eventloop-latency\n\n[![Build Status](https://travis-ci.org/korzhev/eventloop-latency.svg?branch=master)](https://travis-ci.org/korzhev/eventloop-latency)\n[![Coverage Status](https://coveralls.io/repos/github/korzhev/eventloop-latency/badge.svg?branch=master)](https://coveralls.io/github/korzhev/eventloop-latency?branch=master)\n[![Code Climate](https://codeclimate.com/github/korzhev/eventloop-latency/badges/gpa.svg)](https://codeclimate.com/github/korzhev/eventloop-latency)\n[![Issue Count](https://codeclimate.com/github/korzhev/eventloop-latency/badges/issue_count.svg)](https://codeclimate.com/github/korzhev/eventloop-latency)\n\nThis lib is part of [Bronitor](https://github.com/korzhev/bronitor) project. It counts eventloop latency using [process.hrtime](https://nodejs.org/dist/latest-v4.x/docs/api/process.html#process_process_hrtime)\n\n## Requirements\n**Code written using ECMAScript 2015. It tested on node \u003e= 4**\n\nUse babel if, you want to use it on node \u003c 4\n\n## Installation\n```bash\n$ npm i eventloop-latency --production\n```\n\n## Usage\n```js\nconst EL = require('eventloop-latency'),\n\tinterval = 5000, \n\thrInterval = 10, \n\tmonitoring = new EL(interval, hrInterval);\n   \nmonitoring.start(true);   \nmonitoring.on('data', (data) =\u003e {\n  console.log(data); // [49, 27, ..., 144, 923]\n});\nmonitoring.stop();\n  \nmonitoring.start();\nsetInterval(() =\u003e {\n   console.log(monitoring.countLatency()); // [149, 7, ..., 14, 92]\n}, 1000) \n```\n\n## Docs\n- **monitoring** - main object, eventemitter, takes two options:\n    - **iterval** - interval in *ms* for emitting **'data' event**, optional, defaults to 5000 *ms*\n    - **hrIntreval** - interval in *ms* using to count latency, should be in range 10-100, optional, defaults to 10 *ms*\n- **start()** - function, that start monitoring, takes option:\n    - **enableEmit** - if *true*, **monitoring** will emit **\"data\" event**, else function **countLatency()** is used to get latency info\n- **stop()** - function, that stop monitoring\n- **countLatency()** - function, that return array with latency\n- **\"data\" event** - returns array of latency in *µs*(microseconds, 10e-6 s) during the **interval**\n\n## Examples\nYou can see small example in **demos/server.js**. Run it:\n```bash\n$ npm run-script demo\n```\n\n## Tests\n  To run the test suite, first install the dependencies, then run `npm test`:\n```bash\n$ npm install\n$ npm test\n```\n\n## License\n  [MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorzhev%2Feventloop-latency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkorzhev%2Feventloop-latency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkorzhev%2Feventloop-latency/lists"}