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
EventTargetPerformance
Properties
| Name | Description |
|---|---|
| EventCounts | 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). |
| InteractionCount | 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. |
| Navigation | Gets 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. |
| OnResourceTimingBufferFull | The event handler of the resourcetimingbufferfull event, fired when the resource timing buffer is full. |
| TimeOrigin | https://w3c.github.io/hr-time/#timeorigin-attribute: the time origin of the global object, in milliseconds since the Unix epoch. |
| Timing | 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. |
EventCounts
Performance.csGets 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.csGets 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.csThe event handler of the resourcetimingbufferfull event, fired when the resource timing buffer is full.
TimeOrigin
Performance.cshttps://w3c.github.io/hr-time/#timeorigin-attribute: the time origin of the global object, in milliseconds since the Unix epoch.
public double TimeOrigin { get; }Timing
Performance.csGets 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; }Property value
See also
Methods
| Name | Description |
|---|---|
| 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.cshttps://w3c.github.io/user-timing/#clearmarks-method: removes the marks of a name, or all the marks, from the performance timeline.
ClearMeasures(string?)
Performance.cshttps://w3c.github.io/user-timing/#clearmeasures-method: removes the measures of a name, or all the measures, from the performance timeline.
Parameters
measureNamestring?- The name of the measures to remove, or null for all the measures.
See also
ClearResourceTimings()
Performance.cshttps://w3c.github.io/resource-timing/#dom-performance-clearresourcetimings: removes the entries of the resource timing buffer.
public void ClearResourceTimings()GetEntries()
Performance.cshttps://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.cshttps://w3c.github.io/performance-timeline/#getentriesbyname-method
public IReadOnlyList<PerformanceEntry> GetEntriesByName(string name, string? type = null)GetEntriesByType(string)
Performance.cshttps://w3c.github.io/performance-timeline/#getentriesbytype-method
public IReadOnlyList<PerformanceEntry> GetEntriesByType(string type)Mark(string, PerformanceMarkOptions?)
Performance.cshttps://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
markNamestring- The name of the mark.
markOptionsPerformanceMarkOptions?- The time and the data of the mark.
Returns
PerformanceMark The mark.
See also
Measure(string, object?, string?)
Performance.cshttps://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
measureNamestring- The name of the measure.
startOrMeasureOptionsobject?- The start of the measure (a string), a
PerformanceMeasureOptions, or null: the measure starts at the time origin. endMarkstring?- 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
SyntaxErrorwhen a mark does not exist; anInvalidAccessErrorwhen an attribute ofPerformanceTimingis not set yet.
See also
MeasureUserAgentSpecificMemory()
MemoryMeasurement.csEstimates 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()Now()
Performance.cshttps://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.cshttps://w3c.github.io/resource-timing/#dom-performance-setresourcetimingbuffersize: sets the size limit of the resource timing buffer. The entries above the limit are kept.