Skip to content

Conversation

@akki-singh926
Copy link

…e object

docs(perf_hooks): fix eventLoopUtilization examples to use performance object

Summary

This PR fixes the examples for eventLoopUtilization() in the perf_hooks documentation.

Problem

The current documentation incorrectly shows:

import { eventLoopUtilization } from 'node:perf_hooks';

SyntaxError: The requested module 'node:perf_hooks' does not provide an export named 'eventLoopUtilization'
Solution

eventLoopUtilization() is a method of the performance object. The examples have been updated to correctly use:

ES Modules (mjs):

import { performance } from 'node:perf_hooks';
import { spawnSync } from 'node:child_process';

setImmediate(() => {
  const elu = performance.eventLoopUtilization();
  spawnSync('sleep', ['5']);
  console.log(performance.eventLoopUtilization(elu).utilization);
});
CommonJS (cjs):

'use strict';
const { performance } = require('node:perf_hooks');
const { spawnSync } = require('node:child_process');

setImmediate(() => {
  const elu = performance.eventLoopUtilization();
  spawnSync('sleep', ['5']);
  console.log(performance.eventLoopUtilization(elu).utilization);
});
A note has been added clarifying that eventLoopUtilization() must be accessed via performance and is not exported directly.

Signed-off-by: Akki Singh akkisingh952380@gmail.com
'

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to the documentations. perf_hooks Issues and PRs related to the implementation of the Performance Timing API. labels Oct 26, 2025
@aduh95
Copy link
Contributor

aduh95 commented Oct 27, 2025

There are conflicts that must be resolved

@akki-singh926
Copy link
Author

Thank you for the feedback! I’ve resolved the merge conflicts and updated the documentation accordingly.

@akki-singh926
Copy link
Author

thanks! I’ve resolved the conflicts and added the Node.js browser note as suggested. The section now correctly uses performance.eventLoopUtilization() and includes the note. ✅

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why delete this?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for pointing that out! I removed this file because it appeared to be obsolete after syncing with the updated V8 tests. However, if it’s still required for regression coverage, I can restore it in the next commit. Please confirm your preference.

Copy link
Member

@legendecas legendecas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The doc of performance.eventLoopUtilization was intentionally moved to https://github.com/nodejs/node/blob/main/doc/api/perf_hooks.md#perf_hookseventlooputilizationutilization1-utilization2.

The performance.eventLoopUtilization is now an alias of perf_hooks.eventLoopUtilization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc Issues and PRs related to the documentations. perf_hooks Issues and PRs related to the implementation of the Performance Timing API.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants