Measures event loop lag on browsers or node.
Just a fork of event-loop-lag but works on both nodejs environment and browsers.
$ npm i cross-event-loop-lag
import {factory} from 'cross-event-loop-lag'
const interval = 50
const lag = factory(interval)
someHeavyMethod()
lag() // 500, get the lag measurement
- interval
number
The number of milliseconds representing how often to refresh the event loop lag measurement.
Creates a function lag
which can be invoked to return the latest lag measurement in ms. Besides, we can use lag.destroy()
to stop the measuring and destroy the timer inside.
After lag.destroy()
ed, lag()
will always return 0
// Destroy the timer and stop measuring
lag.destroy()
lag() // 0
lag() // 0
MIT