Skip to main content

Module perf_hooks

Module perf_hooks 

Source
Expand description

Node perf_hooks module.

Exposes the performance object. performance.now() returns REAL monotonic milliseconds elapsed since a process-start reference captured lazily in a OnceLock (std::time::Instant — a true monotonic clock, never faked or fuzzed). timeOrigin is the wall-clock time (Unix ms) at that same reference point, so timeOrigin + now() approximates Date.now() as Node guarantees.

mark/measure/getEntriesByName/getEntriesByType/clearMarks are implemented against a small in-process entry buffer guarded by a Mutex. This is best-effort: entries accumulate for the life of the process and the buffer is not bounded (Node’s PerformanceObserver / buffered-entry eviction is not modeled), but marks and measures created and queried within a run behave correctly.

performance is surfaced as a Builtin("performance") namespace value, so performance.now() dispatches through call_method → call_builtin_function (“performance.now”) → this module’s call, and performance.timeOrigin reads through namespace_property → this module’s constant. The parent wires BOTH the perf_hooks and performance namespaces to call/constant (see the wiring note in the accompanying report).

Constants§

HISTOGRAM_METHODS
Methods dispatched on an @@native = "Histogram" object (from createHistogram() / monitorEventLoopDelay(); reported to the parent for instance_has_method / instance_call wiring).
METHODS
Methods available on both the perf_hooks module and its performance object. (timeOrigin is a data property, served by constant.)
OBSERVER_ENTRY_LIST_METHODS
Methods dispatched on an @@native = "PerformanceObserverEntryList" object.
PERFORMANCE_OBSERVER_METHODS
Methods dispatched on an @@native = "PerformanceObserver" object.

Functions§

call
constant
Non-function properties of perf_hooks / performance.
construct
new PerformanceObserver(callback) — build an observer holding its callback, its subscribed entry types, and a pending-entries buffer. Reported to the parent for construct wiring.
entry_list_instance_call
Dispatch a method on a PerformanceObserverEntryList instance.
histogram_instance_call
Dispatch a method on a Histogram instance (@@native = "Histogram").
observer_instance_call
Dispatch a method on a PerformanceObserver instance.