bripkens / event-loop-stats

Exposes stats about the libuv default loop

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect stats

rochdev opened this issue · comments

When I manually block the event loop for a full second with a while loop, event-loop-stats will still report a maximum way below that, for example 5ms. Is there something I don't understand about how to use the library? I call eventLoopStats.sense() every second.

For example:

const els = require('event-loop-stats')

console.log(els.sense())

const end = Date.now() + 50

setTimeout(() => {
  console.log(els.sense())
}, 100)

while (Date.now() < end) {}

This blocks the loop for 50ms, yet this is what is reported:

{ min: 0, max: 0, num: 0, sum: 0 }
{ min: 0, max: 0, num: 2, sum: 0 }

Doing it synchronously yields the same result, except that num is 0.

Hi Roch,

[...] is there something I don't understand about how to use the library? [...]

No, you are absolutely correct, I think this is a bug. Thanks for reporting this. A fix is in the making (#7).

Kind regards from your fellow APM friends at Instana ;-)

Ben and Bastian