performanceNodeTiming.uvMetricsInfo


  • 类型:<Object>
    • loopCount <number> 事件循环迭代次数。
    • events <number> 事件处理器已处理的事件数量。
    • eventsWaiting <number> 在调用事件提供程序时,正在等待处理的事件数量。

这是 uv_metrics_info 函数的封装。它返回当前的一组事件循环指标。

🌐 This is a wrapper to the uv_metrics_info function. It returns the current set of event loop metrics.

这些数值精确到 Number.MAX_SAFE_INTEGER。使用 performanceNodeTiming.uvMetricsInfoBigInt 可以获取 libuv 报告的完整 64 位数值。

🌐 The values are exact up to Number.MAX_SAFE_INTEGER. Use performanceNodeTiming.uvMetricsInfoBigInt to obtain the full 64-bit values reported by libuv.

建议在使用 setImmediate 安排执行的函数中使用此属性,以避免在完成当前循环迭代期间安排的所有操作之前收集指标。

🌐 It is recommended to use this property inside a function whose execution was scheduled using setImmediate to avoid collecting metrics before finishing all operations scheduled during the current loop iteration.

const { performance } = require('node:perf_hooks');

setImmediate(() => {
  console.log(performance.nodeTiming.uvMetricsInfo);
});import { performance } from 'node:perf_hooks';

setImmediate(() => {
  console.log(performance.nodeTiming.uvMetricsInfo);
});