Table of Contents

Class Performance

Namespace
CSharpToJavaScript.APIs.JS
Assembly
CSharpToJavaScript.dll

The Performance interface provides access to performance-related information for the current page.

[Value("Performance")]
public class Performance : EventTarget
Inheritance
Performance
Inherited Members

Remarks

Performance entries are specific to each execution context. You can access performance information for code running in a window via Window.Performance, and for code running in a worker via WorkerGlobalScope.Performance.

See also on MDN

Constructors

Performance()

public Performance()

Properties

EventCounts

The read-only performance.eventCounts property is an EventCounts map containing the number of events which have been dispatched per event type.

[Value("eventCounts")]
public EventCounts EventCounts { get; }

Property Value

EventCounts

An EventCounts map.
(A read-only Map without the clear(), delete(), and set() methods).

Remarks

Not all event types are exposed. You can only get counts for event types supported by the PerformanceEventTiming interface.

-EventCounts
-PerformanceEventTiming
-Map

See also on MDN

InteractionCount

[Value("interactionCount")]
public ulong InteractionCount { get; }

Property Value

ulong

Navigation

IMPORTANT
Deprecated
The legacy
Performance.navigation
read-only property returns a PerformanceNavigation object representing
the type of navigation that occurs in the given browsing context, such as the number of
redirections needed to fetch the resource.
[Value("navigation")]
public PerformanceNavigation Navigation { get; }

Property Value

PerformanceNavigation

A PerformanceNavigation object.

Remarks

This property is not available in workers.

WARNING

This property is deprecated in the Navigation Timing Level 2 specification. Please use the
PerformanceNavigationTiming interface instead.

-The Performance interface it belongs to.

See also on MDN

Onresourcetimingbufferfull

[Value("onresourcetimingbufferfull")]
public EventHandlerNonNull Onresourcetimingbufferfull { get; set; }

Property Value

EventHandlerNonNull

TimeOrigin

The timeOrigin read-only property of the Performance interface returns the high resolution timestamp that is used as the baseline for performance-related timestamps.

[Value("timeOrigin")]
public Number TimeOrigin { get; }

Property Value

Number

A high resolution timestamp which considered to be the beginning of the current document's lifetime. It's calculated like this:

Remarks

In Window contexts, this value represents the time when navigation has started. In Worker and ServiceWorker contexts, this value represents the time when the worker is run. You can use this property to synchronize the time origins between the contexts (see example below).

NOTE

The value of performance.timeOrigin may differ from the value returned by DateNow executed at the time origin, because Date.now() may have been impacted by system and user clock adjustments, clock skew, etc. The timeOrigin property is a monotonic clock which current time never decreases and which isn't subject to these adjustments.

See also on MDN

Timing

IMPORTANT
Deprecated
The legacy
Performance.timing read-only
property returns a PerformanceTiming object containing latency-related
performance information.
[Value("timing")]
public PerformanceTiming Timing { get; }

Property Value

PerformanceTiming

A PerformanceTiming object.

Remarks

This property is not available in workers.

WARNING

This property is deprecated in the Navigation Timing Level 2 specification. Please use the PerformanceNavigationTiming
interface instead.

-The Performance interface it belongs to.

See also on MDN

Methods

ClearMarks(string)

The clearMarks() method removes all or specific PerformanceMark objects from the browser's performance timeline.

[Value("clearMarks")]
public GlobalObject.Undefined ClearMarks(string markName = null)

Parameters

markName string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

ClearMeasures(string)

The clearMeasures() method removes all or specific PerformanceMeasure objects from the browser's performance timeline.

[Value("clearMeasures")]
public GlobalObject.Undefined ClearMeasures(string measureName = null)

Parameters

measureName string

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

ClearResourceTimings()

The clearResourceTimings() method removes all performance entries with an EntryType of "resource" from the browser's performance timeline and sets the size of the performance resource data buffer to zero.

[Value("clearResourceTimings")]
public GlobalObject.Undefined ClearResourceTimings()

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

To set the size of the browser's performance resource data buffer, use the
SetResourceTimingBufferSize(ulong) method.

To get notified when the browser's resource timing buffer is full, listen for the Performance.Resourcetimingbufferfull event.

-SetResourceTimingBufferSize(ulong)
-Performance.Resourcetimingbufferfull

See also on MDN

GetEntries()

The getEntries() method returns an array of all PerformanceEntry objects currently present in the performance timeline.

[Value("getEntries")]
public List<PerformanceEntry> GetEntries()

Returns

List<PerformanceEntry>

An {{jsxref("Array")}} of PerformanceEntry objects. The items will be in chronological order based on the entries' StartTime.

Remarks

If you are only interested in performance entries of certain types or that have certain names, see GetEntriesByType(string) and GetEntriesByName(string, string).

NOTE

This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method.
To receive notifications about entries as they become available, use a PerformanceObserver.

The following entry types are not supported by this method at all and won&apos;t be returned even if entries for these types might exist:

To access entries of these types, you must use a PerformanceObserver instead.

-GetEntriesByType(string)
-GetEntriesByName(string, string)

See also on MDN

GetEntriesByName(string, string)

The getEntriesByName() method returns an array of PerformanceEntry objects currently present in the performance timeline with the given name and type.

[Value("getEntriesByName")]
public List<PerformanceEntry> GetEntriesByName(string name, string type = null)

Parameters

name string
type string

Returns

List<PerformanceEntry>

An {{jsxref("Array")}} of PerformanceEntry objects that have the specified name and type.
The items will be in chronological order based on the entries' StartTime. If no objects meet the
specified criteria, an empty array is returned.

Remarks

If you are interested in performance entries of certain types, see GetEntriesByType(string). For all performance entries, see GetEntries().

NOTE

This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method.
To receive notifications about entries as they become available, use a PerformanceObserver.

The following entry types are not supported by this method at all and won&apos;t be returned even if entries for these types might exist:

To access entries of these types, you must use a PerformanceObserver instead.

-GetEntries()
-GetEntriesByType(string)

See also on MDN

GetEntriesByType(string)

The getEntriesByType() method returns an array of PerformanceEntry objects currently present in the performance timeline for a given type.

[Value("getEntriesByType")]
public List<PerformanceEntry> GetEntriesByType(string type)

Parameters

type string

Returns

List<PerformanceEntry>

An {{jsxref("Array")}} of PerformanceEntry objects that have the specified type. The items will be in chronological order based on the entries' StartTime. If no objects have the specified type, or no argument is provided, an empty array is returned.

Remarks

If you are interested in performance entries of certain name, see GetEntriesByName(string, string). For all performance entries, see GetEntries().

NOTE

This method does not notify you about new performance entries; you will only get entries that are present in the performance timeline at the time you call this method.
To receive notifications about entries as they become available, use a PerformanceObserver.

The following entry types are not supported by this method at all and won&apos;t be returned even if entries for these types might exist:

To access entries of these types, you must use a PerformanceObserver instead.

-GetEntries()
-GetEntriesByName(string, string)
-SupportedEntryTypes

See also on MDN

Mark(string, PerformanceMarkOptions)

The mark() method creates a named PerformanceMark object representing a high resolution timestamp marker in the browser's performance timeline.

[Value("mark")]
public PerformanceMark Mark(string markName, PerformanceMarkOptions markOptions = null)

Parameters

markName string
markOptions PerformanceMarkOptions

Returns

PerformanceMark

The PerformanceMark entry that was created.

Remarks

Measure(string, Union158, string)

The measure() method creates a named PerformanceMeasure object representing a time measurement between two marks in the browser's performance timeline.

[Value("measure")]
public PerformanceMeasure Measure(string measureName, Union158 startOrMeasureOptions = default, string endMark = null)

Parameters

measureName string
startOrMeasureOptions Union158
endMark string

Returns

PerformanceMeasure

The PerformanceMeasure entry that was created.The returned measure will have the following property values:

Remarks

When measuring between two marks, there is a start mark and end mark, respectively.
The named timestamp is referred to as a measure.

See also on MDN

MeasureUserAgentSpecificMemory()

NOTE
Experimental
The measureUserAgentSpecificMemory() method is used to estimate the memory usage of a web application including all its iframes and workers.
[Value("measureUserAgentSpecificMemory")]
public Task<MemoryMeasurement> MeasureUserAgentSpecificMemory()

Returns

Task<MemoryMeasurement>

A Promise that resolves to an object containing the following properties:An example return value looks like this:

Remarks

Now()

The performance.now() method returns a high resolution timestamp in milliseconds. It represents the time elapsed since TimeOrigin (the time when navigation has started in window contexts, or the time when the worker is run in Worker and ServiceWorker contexts).

[Value("now")]
public Number Now()

Returns

Number

Returns a Number measured in milliseconds.

Remarks

SetResourceTimingBufferSize(ulong)

The setResourceTimingBufferSize() method sets the desired size of the browser&apos;s resource timing buffer which stores the &quot;resource&quot; performance entries.

[Value("setResourceTimingBufferSize")]
public GlobalObject.Undefined SetResourceTimingBufferSize(ulong maxSize)

Parameters

maxSize ulong

Returns

GlobalObject.Undefined

None (GlobalObject.Undefined).

Remarks

The specification requires the resource timing buffer initially to be 250 or greater.

To clear the browser&apos;s performance resource data buffer, use the
ClearResourceTimings() method.

To get notified when the browser's resource timing buffer is full, listen for the Performance.Resourcetimingbufferfull event.

-ClearResourceTimings()
-Performance.Resourcetimingbufferfull

See also on MDN

ToJSON()

The toJSON() method of the Performance interface is a {{Glossary("Serialization","serializer")}}; it returns a JSON representation of the Performance object.

[Value("toJSON")]
public Object ToJSON()

Returns

Object

A {{jsxref("JSON")}} object that is the serialization of the Performance object.The returned JSON doesn't contain the EventCounts property because it is of type EventCounts, which doesn't provide a toJSON() operation.

NOTE
The JSON object contains the serialization of the deprecated Timing and Navigation properties. To get a JSON representation of the newer PerformanceNavigationTiming interface, call ToJSON() instead.

Remarks