Usage in Deno
```typescript import * as mod from "node:node__perf_hooks.d.ts"; ```This module provides an implementation of a subset of the W3C [Web Performance APIs](https://w3c.github.io/perf-timing-primer/) as well as additional APIs for
Node.js-specific performance measurements.
Node.js supports the following [Web Performance APIs](https://w3c.github.io/perf-timing-primer/):
* [High Resolution Time](https://www.w3.org/TR/hr-time-2)
* [Performance Timeline](https://w3c.github.io/performance-timeline/)
* [User Timing](https://www.w3.org/TR/user-timing/)
* [Resource Timing](https://www.w3.org/TR/resource-timing-2/)
```js
import { PerformanceObserver, performance } from 'node:perf_hooks';
const obs = new PerformanceObserver((items) => {
console.log(items.getEntries()[0].duration);
performance.clearMarks();
});
obs.observe({ type: 'measure' });
performance.measure('Start to Now');
performance.mark('A');
doSomeLongRunningProcess(() => {
performance.measure('A to Now', 'A');
performance.mark('B');
performance.measure('A to B', 'A', 'B');
});
```
c
v
c
v
c
v
PerformanceMeasure
Exposes measures created via the `Performance.measure()` method.
The constructor of this class is not exposed to users directly.
c
PerformanceNodeTiming
_This property is an extension by Node.js. It is not available in Web browsers._
Provides timing details for Node.js itself. The constructor of this class
is not exposed to users.
c
v
c
v
c
v
PerformanceResourceTiming
Provides detailed network timing data regarding the loading of an application's resources.
The constructor of this class is not exposed to users directly.
f
createHistogram
Returns a `RecordableHistogram`.
f
monitorEventLoopDelay
> [!WARNING] Deno compatibility
> This symbol is not implemented.
_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.
```js
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));
```
I
I
I
I
I
I
I
I
I
I
I
N
constants
No documentation available
T
EntryType
No documentation available
T
EventLoopUtilityFunction
No documentation available
T
PerformanceObserverCallback
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_ALL_AVAILABLE_GARBAGE
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_ALL_EXTERNAL_MEMORY
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_CONSTRUCT_RETAINED
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_FORCED
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_NO
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_SCHEDULE_IDLE
No documentation available
v
constants.NODE_PERFORMANCE_GC_FLAGS_SYNCHRONOUS_PHANTOM_PROCESSING
No documentation available
v
constants.NODE_PERFORMANCE_GC_INCREMENTAL
No documentation available
v
constants.NODE_PERFORMANCE_GC_MAJOR
No documentation available
v
constants.NODE_PERFORMANCE_GC_MINOR
No documentation available
v
constants.NODE_PERFORMANCE_GC_WEAKCB
No documentation available
v
performance
No documentation available