温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/node/perf_hooks/monitorEventLoopDelay
点击访问原文链接

Node perf_hooks.monitorEventLoopDelay function | API Reference | Bun

Node perf_hooks.monitorEventLoopDelay function | API Reference | BunBuildDocsReferenceGuidesBlogDiscord/node:perf_hooks/monitorEventLoopDelayFmonitorEventLoopDelay

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/node:perf_hooks/monitorEventLoopDelayFmonitorEventLoopDelay

function

perf_hooks.monitorEventLoopDelayfunction monitorEventLoopDelay(options?: EventLoopMonitorOptions): IntervalHistogram;This property is an extension by Node.js. It is not available in Web browsers.

Creates an IntervalHistogram object that samples and reports the event loop delay over time. The delays will be reported in nanoseconds.

Using a timer to detect approximate event loop delay works because the execution of timers is tied specifically to the lifecycle of the libuv event loop. That is, a delay in the loop will cause a delay in the execution of the timer, and those delays are specifically what this API is intended to detect.

import { monitorEventLoopDelay } from 'node:perf_hooks'; const h = monitorEventLoopDelay({ resolution: 20 }); h.enable(); // Do something. h.disable(); console.log(h.min); console.log(h.max); console.log(h.mean); console.log(h.stddev); console.log(h.percentiles); console.log(h.percentile(50)); console.log(h.percentile(99)); Referenced typesinterface EventLoopMonitorOptionsresolution?: numberThe sampling rate in milliseconds. Must be greater than zero.

interface IntervalHistogramreadonly count: numberThe number of samples recorded by the histogram.

readonly countBigInt: bigintThe number of samples recorded by the histogram. v17.4.0, v16.14.0

readonly exceeds: numberThe number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.

readonly exceedsBigInt: bigintThe number of times the event loop delay exceeded the maximum 1 hour event loop delay threshold.

readonly max: numberThe maximum recorded event loop delay.

readonly maxBigInt: numberThe maximum recorded event loop delay. v17.4.0, v16.14.0

readonly mean: numberThe mean of the recorded event loop delays.

readonly min: numberThe minimum recorded event loop delay.

readonly minBigInt: bigintThe minimum recorded event loop delay. v17.4.0, v16.14.0

readonly percentiles: Mapnumber, number>Returns a Map object detailing the accumulated percentile distribution.

readonly percentilesBigInt: Mapbigint, bigint>Returns a Map object detailing the accumulated percentile distribution.

readonly stddev: numberThe standard deviation of the recorded event loop delays.

[Symbol.dispose](): void;Disables the update interval timer when the histogram is disposed.

const { monitorEventLoopDelay } = require('node:perf_hooks'); { using hist = monitorEventLoopDelay({ resolution: 20 }); hist.enable(); // The histogram will be disabled when the block is exited. } disable(): boolean;Disables the update interval timer. Returns true if the timer was stopped, false if it was already stopped.

enable(): boolean;Enables the update interval timer. Returns true if the timer was started, false if it was already started.

percentile(percentile: number): number;Returns the value at the given percentile.

@param percentileA percentile value in the range (0, 100].

percentileBigInt(percentile: number): bigint;Returns the value at the given percentile.

@param percentileA percentile value in the range (0, 100].

reset(): void;Resets the collected histogram data.

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco

We're hiring →

智能索引记录