Performance Class

https://w3c.github.io/hr-time/#the-performance-interface, with the extensions of Performance Timeline (https://w3c.github.io/performance-timeline/#extensions-to-the-performance-interface), Resource Timing (https://w3c.github.io/resource-timing/#sec-extensions-performance-interface), User Timing (https://w3c.github.io/user-timing/#extensions-performance-interface) and Navigation Timing (https://w3c.github.io/navigation-timing/#extensions-to-the-performance-interface). It holds the performance timeline of its global object: the performance entry buffer and the registered performance observers.

public sealed class Performance : EventTarget
Inheritance
EventTarget Performance

Properties

NameDescription
EventCountsGets the number of trusted events of each type considered for Event Timing that were dispatched in the window (https://w3c.github.io/event-timing/#dom-performance-eventcounts), or null for a worker. The counts stay at 0 when Event Timing is disabled (WebPlatformFeatures.EventTimingEnabled).
InteractionCountGets the number of interactions of the user with the window (https://w3c.github.io/event-timing/#dom-performance-interactioncount): the presses of a pointer followed by its release, and the presses of a key. It is 0 for a worker.
NavigationGets the legacy description of the navigation of the document of the window (https://w3c.github.io/navigation-timing/#dom-performance-navigation), or null for a worker.
OnResourceTimingBufferFullThe event handler of the resourcetimingbufferfull event, fired when the resource timing buffer is full.
TimeOriginhttps://w3c.github.io/hr-time/#timeorigin-attribute: the time origin of the global object, in milliseconds since the Unix epoch.
TimingGets the legacy timing of the navigation of the document of the window (https://w3c.github.io/navigation-timing/#dom-performance-timing), or null for a worker.

EventCounts

Performance.cs

Gets the number of trusted events of each type considered for Event Timing that were dispatched in the window (https://w3c.github.io/event-timing/#dom-performance-eventcounts), or null for a worker. The counts stay at 0 when Event Timing is disabled (WebPlatformFeatures.EventTimingEnabled).

public EventCounts? EventCounts { get; }

InteractionCount

Performance.cs

Gets the number of interactions of the user with the window (https://w3c.github.io/event-timing/#dom-performance-interactioncount): the presses of a pointer followed by its release, and the presses of a key. It is 0 for a worker.

public ulong InteractionCount { get; }

OnResourceTimingBufferFull

Performance.cs

The event handler of the resourcetimingbufferfull event, fired when the resource timing buffer is full.

public Action<Event>? OnResourceTimingBufferFull { get; set; }

TimeOrigin

Performance.cs

https://w3c.github.io/hr-time/#timeorigin-attribute: the time origin of the global object, in milliseconds since the Unix epoch.

public double TimeOrigin { get; }

Gets the legacy timing of the navigation of the document of the window (https://w3c.github.io/navigation-timing/#dom-performance-timing), or null for a worker.

public PerformanceTiming? Timing { get; }

Methods

NameDescription
ClearMarks(string?)https://w3c.github.io/user-timing/#clearmarks-method: removes the marks of a name, or all the marks, from the performance timeline.
ClearMeasures(string?)https://w3c.github.io/user-timing/#clearmeasures-method: removes the measures of a name, or all the measures, from the performance timeline.
ClearResourceTimings()https://w3c.github.io/resource-timing/#dom-performance-clearresourcetimings: removes the entries of the resource timing buffer.
GetEntries()https://w3c.github.io/performance-timeline/#getentries-method: the entries of the performance entry buffer, in chronological order.
GetEntriesByName(string, string?)https://w3c.github.io/performance-timeline/#getentriesbyname-method
GetEntriesByType(string)https://w3c.github.io/performance-timeline/#getentriesbytype-method
Mark(string, PerformanceMarkOptions?)https://w3c.github.io/user-timing/#mark-method: creates a mark (see PerformanceMark), queues it to the performance observers and adds it to the performance timeline.
Measure(string, object?, string?)https://w3c.github.io/user-timing/#measure-method: creates a measure between two times, queues it to the performance observers and adds it to the performance timeline. A time is the name of a mark (the time of its most recent occurrence), the name of an attribute of PerformanceTiming in a window, or a number of milliseconds.
MeasureUserAgentSpecificMemory()Estimates the memory of the agent cluster of the window or of the worker (https://wicg.github.io/performance-measure-memory/#dom-performance-measureuseragentspecificmemory): one entry per realm of the browsing context group of a window (the documents of its windows and frames, and their dedicated workers), or the realm of the worker, and an empty entry, in a random order. A realm of the origin of the measurement is attributed to its URL, the other realms to cross-origin-url; the container is the iframe element of a document of the origin of the measurement that contains the realm. The sizes are a deterministic estimate of the objects of the library (a base size per realm, the nodes and the text of the documents), not of the JavaScript heap. The method is only exposed to the scripts of the cross-origin isolated windows, service workers and shared workers ([CrossOriginIsolated]). The task fails with a SecurityError DomException when the global object is not cross-origin isolated (GlobalScope.CrossOriginIsolated), and with an InvalidStateError when the document is not fully active.
Now()https://w3c.github.io/hr-time/#now-method: the time elapsed since the time origin of the global object, in milliseconds, measured with DomEventLoop.TimeProvider.
SetResourceTimingBufferSize(uint)https://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize: sets the size limit of the resource timing buffer. The entries above the limit are kept.

ClearMarks(string?)

Performance.cs

https://w3c.github.io/user-timing/#clearmarks-method: removes the marks of a name, or all the marks, from the performance timeline.

public void ClearMarks(string? markName = null)

Parameters

markName string?
The name of the marks to remove, or null for all the marks.

See also

ClearMeasures(string?)

Performance.cs

https://w3c.github.io/user-timing/#clearmeasures-method: removes the measures of a name, or all the measures, from the performance timeline.

public void ClearMeasures(string? measureName = null)

Parameters

measureName string?
The name of the measures to remove, or null for all the measures.

See also

ClearResourceTimings()

Performance.cs

https://w3c.github.io/resource-timing/#dom-performance-clearresourcetimings: removes the entries of the resource timing buffer.

public void ClearResourceTimings()

GetEntries()

Performance.cs

https://w3c.github.io/performance-timeline/#getentries-method: the entries of the performance entry buffer, in chronological order.

public IReadOnlyList<PerformanceEntry> GetEntries()

GetEntriesByName(string, string?)

Performance.cs

https://w3c.github.io/performance-timeline/#getentriesbyname-method

public IReadOnlyList<PerformanceEntry> GetEntriesByName(string name, string? type = null)

GetEntriesByType(string)

Performance.cs

https://w3c.github.io/performance-timeline/#getentriesbytype-method

public IReadOnlyList<PerformanceEntry> GetEntriesByType(string type)

Mark(string, PerformanceMarkOptions?)

Performance.cs

https://w3c.github.io/user-timing/#mark-method: creates a mark (see PerformanceMark), queues it to the performance observers and adds it to the performance timeline.

public PerformanceMark Mark(string markName, PerformanceMarkOptions? markOptions = null)

Parameters

markName string
The name of the mark.
markOptions PerformanceMarkOptions?
The time and the data of the mark.

Returns

PerformanceMark The mark.

See also

Measure(string, object?, string?)

Performance.cs

https://w3c.github.io/user-timing/#measure-method: creates a measure between two times, queues it to the performance observers and adds it to the performance timeline. A time is the name of a mark (the time of its most recent occurrence), the name of an attribute of PerformanceTiming in a window, or a number of milliseconds.

public PerformanceMeasure Measure(string measureName, object? startOrMeasureOptions = null, string? endMark = null)

Parameters

measureName string
The name of the measure.
startOrMeasureOptions object?
The start of the measure (a string), a PerformanceMeasureOptions, or null: the measure starts at the time origin.
endMark string?
The end of the measure, or null for the current time. It cannot be used with options.

Returns

PerformanceMeasure The measure.

Exceptions

TypeErrorException
The options are not valid, or a time is negative.
DomException
A SyntaxError when a mark does not exist; an InvalidAccessError when an attribute of PerformanceTiming is not set yet.

See also

MeasureUserAgentSpecificMemory()

MemoryMeasurement.cs

Estimates the memory of the agent cluster of the window or of the worker (https://wicg.github.io/performance-measure-memory/#dom-performance-measureuseragentspecificmemory): one entry per realm of the browsing context group of a window (the documents of its windows and frames, and their dedicated workers), or the realm of the worker, and an empty entry, in a random order. A realm of the origin of the measurement is attributed to its URL, the other realms to cross-origin-url; the container is the iframe element of a document of the origin of the measurement that contains the realm. The sizes are a deterministic estimate of the objects of the library (a base size per realm, the nodes and the text of the documents), not of the JavaScript heap. The method is only exposed to the scripts of the cross-origin isolated windows, service workers and shared workers ([CrossOriginIsolated]). The task fails with a SecurityError DomException when the global object is not cross-origin isolated (GlobalScope.CrossOriginIsolated), and with an InvalidStateError when the document is not fully active.

public Task<MemoryMeasurement> MeasureUserAgentSpecificMemory()

https://w3c.github.io/hr-time/#now-method: the time elapsed since the time origin of the global object, in milliseconds, measured with DomEventLoop.TimeProvider.

public double Now()

SetResourceTimingBufferSize(uint)

Performance.cs

https://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize: sets the size limit of the resource timing buffer. The entries above the limit are kept.

public void SetResourceTimingBufferSize(uint maxSize)