cross-event-loop-lag
v1.0.0
Published
Measures event loop log on browsers or nodejs.
Downloads
6
Maintainers
Readme
cross-event-loop-lag
Measures event loop lag on browsers or node.
Just a fork of event-loop-lag but works on both nodejs environment and browsers.
Install
$ npm i cross-event-loop-lag
Usage
import {factory} from 'cross-event-loop-lag'
const interval = 50
const lag = factory(interval)
someHeavyMethod()
lag() // 500, get the lag measurement
factory(interval: number)
- 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
License
MIT