On this page

P

perf_hooks.performance

History

An object that can be used to collect performance metrics from the current Node.js instance. It is similar to window.performance in browsers.

performance.clearMarks(name?): void
Attributes
name:string

If name is not provided, removes all PerformanceMark objects from the Performance Timeline. If name is provided, removes only the named mark.

performance.clearMeasures(name?): void
Attributes
name:string

If name is not provided, removes all PerformanceMeasure objects from the Performance Timeline. If name is provided, removes only the named measure.

performance.clearResourceTimings(name?): void
Attributes
name:string

If name is not provided, removes all PerformanceResourceTiming objects from the Resource Timeline. If name is provided, removes only the named resource.

performance.eventLoopUtilization(utilization1?, utilization2?): Object
Attributes
utilization1:Object
The result of a previous call to eventLoopUtilization().
utilization2:Object
The result of a previous call to eventLoopUtilization() prior to utilization1.
Returns:Object
idle:number
active:number
utilization:number

This is an alias of perf_hooks.eventLoopUtilization().

This property is an extension by Node.js. It is not available in Web browsers.

performance.getEntries(): PerformanceEntry[]

Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime. If you are only interested in performance entries of certain types or that have certain names, see performance.getEntriesByType() and performance.getEntriesByName().

performance.getEntriesByName(name, type?): PerformanceEntry[]
Attributes
name:string
type:string

Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime whose performanceEntry.name is equal to name, and optionally, whose performanceEntry.entryType is equal to type.

performance.getEntriesByType(type): PerformanceEntry[]
Attributes
type:string

Returns a list of PerformanceEntry objects in chronological order with respect to performanceEntry.startTime whose performanceEntry.entryType is equal to type.

performance.mark(name, options?): void
Attributes
name:string
options:Object
detail:any
Additional optional detail to include with the mark.
startTime:number
An optional timestamp to be used as the mark time. Default: performance.now().

Creates a new PerformanceMark entry in the Performance Timeline. A PerformanceMark is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'mark', and whose performanceEntry.duration is always 0. Performance marks are used to mark specific significant moments in the Performance Timeline.

The created PerformanceMark entry is put in the global Performance Timeline and can be queried with performance.getEntries, performance.getEntriesByName, and performance.getEntriesByType. When the observation is performed, the entries should be cleared from the global Performance Timeline manually with performance.clearMarks.

performance.markResourceTiming(timingInfo, requestedUrl, initiatorType, global, cacheMode, bodyInfo, responseStatus, deliveryType?): void
Attributes
requestedUrl:string
The resource url
initiatorType:string
The initiator name, e.g: 'fetch'
global:Object
cacheMode:string
The cache mode must be an empty string ('') or 'local'
responseStatus:number
The response's status code
deliveryType?:string
The delivery type. Default: ''.

This property is an extension by Node.js. It is not available in Web browsers.

Creates a new PerformanceResourceTiming entry in the Resource Timeline. A PerformanceResourceTiming is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'resource'. Performance resources are used to mark moments in the Resource Timeline.

The created PerformanceMark entry is put in the global Resource Timeline and can be queried with performance.getEntries, performance.getEntriesByName, and performance.getEntriesByType. When the observation is performed, the entries should be cleared from the global Performance Timeline manually with performance.clearResourceTimings.

performance.measure(name, startMarkOrOptions?, endMark?): void
Attributes
name:string
startMarkOrOptions:string | Object
Optional.
detail:any
Additional optional detail to include with the measure.
duration:number
Duration between start and end times.
Timestamp to be used as the end time, or a string identifying a previously recorded mark.
start:number | string
Timestamp to be used as the start time, or a string identifying a previously recorded mark.
endMark:string
Optional. Must be omitted if startMarkOrOptions is an Object.

Creates a new PerformanceMeasure entry in the Performance Timeline. A PerformanceMeasure is a subclass of PerformanceEntry whose performanceEntry.entryType is always 'measure', and whose performanceEntry.duration measures the number of milliseconds elapsed since startMark and endMark.

The startMark argument may identify any existing PerformanceMark in the Performance Timeline, or may identify any of the timestamp properties provided by the PerformanceNodeTiming class. If the named startMark does not exist, an error is thrown.

The optional endMark argument must identify any existing PerformanceMark in the Performance Timeline or any of the timestamp properties provided by the PerformanceNodeTiming class. endMark will be performance.now() if no parameter is passed, otherwise if the named endMark does not exist, an error will be thrown.

The created PerformanceMeasure entry is put in the global Performance Timeline and can be queried with performance.getEntries, performance.getEntriesByName, and performance.getEntriesByType. When the observation is performed, the entries should be cleared from the global Performance Timeline manually with performance.clearMeasures.

P

performance.nodeTiming

History

This property is an extension by Node.js. It is not available in Web browsers.

An instance of the PerformanceNodeTiming class that provides performance metrics for specific Node.js operational milestones.

performance.now(): number
Returns:number

Returns the current high resolution millisecond timestamp, where 0 represents the start of the current node process.

performance.setResourceTimingBufferSize(maxSize): void

Sets the global performance resource timing buffer size to the specified number of "resource" type performance entry objects.

By default the max buffer size is set to 250.

P

performance.timeOrigin

History
Type:number

The timeOrigin specifies the high resolution millisecond timestamp at which the current node process began, measured in Unix time.

performance.timerify(fn, options?): void
Attributes
options:Object
A histogram object created using perf_hooks.createHistogram() that will record runtime durations in nanoseconds.

This is an alias of perf_hooks.timerify().

This property is an extension by Node.js. It is not available in Web browsers.

performance.toJSON(): void

An object which is JSON representation of the performance object. It is similar to window.performance.toJSON in browsers.

E

resourcetimingbufferfull

History

The 'resourcetimingbufferfull' event is fired when the global performance resource timing buffer is full. Adjust resource timing buffer size with performance.setResourceTimingBufferSize() or clear the buffer with performance.clearResourceTimings() in the event listener to allow more entries to be added to the performance timeline buffer.