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.】

建议在使用 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);
});