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);
});