event-loop-delay
A minimal overhead event loop delay sampler.
Last updated 6 years ago by mafintosh .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install event-loop-delay 
SYNC missed versions from official npm registry.

event-loop-delay

A minimal overhead event loop delay sampler.

npm install event-loop-delay

Bundles a prebuilt N-API addon that makes the overhead of the sampler very minimal (around 0.2% on my machine, ymmv).

If the addon fails for some reason a JS fallback is used with a bit higher overhead (around 1-2% on my machine).

Usage

const loopDelay = require('event-loop-delay')

const sampler = loopDelay()

setInterval(function () {
  console.log('Accumulated delay in ms is', sampler.delay)
  console.log('Accumulated times a delay was detected', sampler.times)
}, 1000)

setInterval(function () {
  for (let i = 0; i < 1e7; i++) {
    // simulate event loop blocking
  }
}, 3000)

Running the above should run the sampler measuring the event loop delay.

API

sampler = loopDelay()

Make a new sampler. Will sample the event loop every 10ms.

sampler.delay

Accumulated event loop delay in ms measured since sampler was created.

sampler.times

Accumulated times the event loop delay was detected.

sampler.destroy()

Destroys the sampler.

sampler.native

Boolean telling you if the native addon is used.

License

MIT

Current Tags

  • 1.1.0                                ...           latest (a month ago)

4 Versions

  • 1.1.0                                ...           a month ago
  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Total 5
Today 1
This Week 1
This Month 2
Last Day 0
Last Week 1
Last Month 0
Dependencies (2)
Dev Dependencies (1)
Dependents (1)

© 2010 - cnpmjs.org x YWFE | Home | YWFE