new LatencyMonitor( [latencyCheckIntervalMs] [, dataEmitIntervalMs] [, asyncTestFn] [, latencyRandomPercentage])
Parameters:
Name | Type | Argument | Default | Description |
---|---|---|---|---|
latencyCheckIntervalMs |
Number |
<optional> |
500 | How often to add a latency check event (ms) |
dataEmitIntervalMs |
Number |
<optional> |
5000 | How often to summarize latency check events. null or 0 disables event firing |
asyncTestFn |
function |
<optional> |
What cb-style async function to use |
|
latencyRandomPercentage |
Number |
<optional> |
5 | What percent (+/-) of latencyCheckIntervalMs should we randomly use? This helps avoid alignment to other events. |
Examples
const monitor = new LatencyMonitor(); monitor.on('data', (summary) => console.log('Event Loop Latency: %O', summary));
const monitor = new LatencyMonitor({latencyCheckIntervalMs: 1000, dataEmitIntervalMs: 60000, asyncTestFn:ping}); monitor.on('data', (summary) => console.log('Ping Pong Latency: %O', summary));
Methods
-
getSummary()
-
Calling this function will end the collection period. If a timing event was already fired and somewhere in the queue, it will not count for this time period
Returns:
- Type
- SummaryObject