pebble/event-loop-lag

Negative time reported

Closed this issue · 4 comments

This module reports negative times now and then. This is due to the measurement method. Maybe a better method would be to schedule a setImmediate() on the timeout and measure the lag of that?

Could you explain why that's better? I'm thinking the occasional negative value is due to how timers are implemented. Probably just return 0 if we go negative.

You want to measure NodeJS cycle time right? What you're seeing now is cycletime + timer-noise. Measuring with setImmediate uses a simpler implementation underwater (hence less noise) and you will always get a positive outcome. In other words, you get closer to the value you want to measure.

nice. PR?