performance
WebAPI-style benchmarking API
For more information, see: https://developer.mozilla.org/en-US/docs/Web/API/Performance_API
WebAPI-style benchmarking API
For more information, see: https://developer.mozilla.org/en-US/docs/Web/API/Performance_API
timeOrigin: number = 0.0 };
Read-only property of the Performance interface returns the high resolution timestamp that is used as the baseline for performance-related timestamps.
In JSplitter context this value represents the "UNIX-time" (milliseconds since 1 January 1970) when script was loaded.
0.0 };
clearMarks(name)
Removes all or specific PerformanceEntry objects from the player's performance timeline.
| Name | Type | Description |
|---|---|---|
name = ''optional | string | A string representing the name of the PerformanceEntry object. If this argument is omitted, all entries with an entryType of "mark" will be removed. |
clearMeasures(name)
Removes all or specific PerformanceEntry objects from the player's performance timeline.
| Name | Type | Description |
|---|---|---|
name = ''optional | string | A string representing the name of the PerformanceEntry object. If this argument is omitted, all entries with an entryType of "measure" will be removed. |
getEntries()
Returns an array of all PerformanceEntry objects currently present in the performance timeline.
If you are only interested in performance entries of certain types ("mark" or "measure") or that have certain names, see getEntriesByType and getEntriesByName.
Array<PerformanceEntry>getEntriesByName(name, type)
Returns an array of PerformanceEntry objects currently present in the performance timeline with the given name and type ("mark" or "measure").
If you are interested in performance entries of certain types, see getEntriesByType. For all performance entries, see getEntries.
| Name | Type | Description |
|---|---|---|
name | string | A string representing the name of the measure. |
type = ''optional | string | A string representing the name of the measure. |
Array<PerformanceEntry>getEntriesByType(type)
Returns an array of PerformanceEntry objects currently present in the performance timeline for a given type ("mark" or "measure").
If you are interested in performance entries of certain name, see getEntriesByName. For all performance entries, see getEntries.
| Name | Type | Description |
|---|---|---|
type | string | A string representing the name of the measure. |
Array<PerformanceEntry>mark(name, markOptions)
Creates a named PerformanceEntry object representing a high resolution timestamp marker in the player's performance timeline
| Name | Type | Description |
|---|---|---|
name | string | A string representing the name of the mark. |
markOptions = nulloptional | object | An object for specifying a timestamp and additional metadata for the mark. |
performance.mark('work-begin', { detail: { description: "Begin of some important work", id: 777 } });
doSomething();
performance.mark('work-end');
const measure = performance.measure('work-duration', 'work-begin', 'work-end');
const beginMark = performance.getEntriesByName('work-begin')[0];
console.log(`"${beginMark.detail.description}" started for id = ${beginMark.detail.id} executed in ${measure.duration} ms`);
performance.clearMarks();
performance.clearMeasures();
measure(measureName, startMark, endMark, measureOptions)
Creates a named PerformanceEntry object representing a time measurement between two marks in the player's performance timeline.
When measuring between two marks, there is a start mark and end mark, respectively. The named timestamp is referred to as a measure.
If only measureName is specified, the start timestamp is set to zero, and the end timestamp (which is used to calculate the duration) is the value that would be returned by performance.now()
| Name | Type | Description |
|---|---|---|
measureName | string | A string representing the name of the measure. |
startMark = ''optional | string | A string naming a PerformanceEntry with "mark" type in the performance timeline. The PerformanceEntry.startTime property of this mark will be used for calculating the measure. |
endMark = ''optional | string | A string naming a PerformanceEntry with "mark" type in the performance timeline. The PerformanceEntry.startTime property of this mark will be used for calculating the measure. |
measureOptions = nulloptional | object | An object for specifying a timestamp and additional metadata for the mark. |
now()
Returns a high resolution timestamp in milliseconds with a fractional part. It represents the time elapsed since performance.timeOrigin (the time when script was loaded)
Unlike Date.now, the timestamps returned by performance.now() are not limited to one-millisecond resolution. Instead, they represent times as floating-point numbers with up to microsecond precision.
Also, Date.now() may have been impacted by system and user clock adjustments, clock skew, etc. as it is relative to the Unix epoch (1970-01-01T00:00:00Z) and dependent on the system clock.
The performance.now() method on the other hand is relative to the timeOrigin property which is a monotonic clock: its current time never decreases and isn't subject to adjustments.
numberconst t0 = performance.now();
doSomething();
const t1 = performance.now();
console.log(`Call to doSomething took ${t1 - t0} milliseconds.`);
Observer(callback)
Creates and returns a new PerformanceObserver object.
The observer callback is invoked when performance entry events are recorded by performance.mark() or performance.measure() calls for the entry types that have been registered, via the observe() method.
| Name | Type | Description |
|---|---|---|
callback | function |
toString(measureName, startMark, endMark, measureOptions)
Returns string representation of Performance object.
This gives you a list of all performance entries in a human-readable form.
string