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.
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

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)