The High Resolution Time standard defines a Performance interface that supports client-side latency measurements within applications. The Performance interfaces are considered high resolution because they are accurate to a thousandth of a millisecond (subject to hardware or software constraints). The interfaces support a number of use cases including calculating frame-rates (potentially important in animations) and benchmarking (such as the time to load a resource).
Since a platform's system clock is subject to various skews (such as NTP adjustments), the interfaces support a monotonic clock i.e. a clock that is always increasing. As such, the Performance API defines a DOMHighResTimeStamp type rather than using the Date.now() interface.
The DOMHighResTimeStamp type, as its name implies, represents a high resolution point in time. This type is a double and is used by the performance interfaces. The value could be a discrete point in time or the difference in time between two discrete points in time.
The unit of DOMHighResTimeStamp is milliseconds and should be accurate to 5 µs (microseconds). However, If the browser is unable to provide a time value accurate to 5 microseconds (because, for example, due to hardware or software constraints), the browser can represent a the value as a time in milliseconds accurate to a millisecond.
The interface has two methods. The Performancenow() method returns a DOMHighResTimeStamp whose value that depends on the navigation start and scope. If the scope is a window, the value is the time the browser context was created and if the scope is a worker, the value is the time the worker was created.
The toJSON() method returns a serialization of the Performance object, for those attributes that can be serialized.
The interface has two properties. The Performancetiming property returns a PerformanceTiming object containing latency-related performance information such as the start of navigation time, start and end times for redirects, start and end times for responses, etc.
The property returns a navigationPerformanceNavigation object representing the type of navigation that occurs in the given browsing context, such as the page was navigated to from history, the page was navigated to by following a link, etc.
PerformancePerformanceEntryPerformanceFrameTimingPerformanceMarkperformance entries with an entry type of "mark". Entries of this type are created by calling performance.mark() to add a named DOMHighResTimeStamp (the mark) to the browser's performance timeline.PerformanceMeasureperformance entries with an entry type of "measure". Entries of this type are created by calling performance.measure() to add a namedDOMHighResTimeStamp (the measure) between two marks to the browser's performance timeline.PerformanceNavigationTiminghigh resolution timestamps or metrics regarding the browser's document navigation events. PerformanceObserverPerformanceResourceTiming| Specification | Status | Comment |
|---|---|---|
| High Resolution Time | Recommendation | Initial definition. |
| High Resolution Time Level 2 | Candidate Recommendation | Adds performance attribute on Window and WorkerGlobalScope. |
| High Resolution Time Level 3 | Editor's Draft | Add timeOrigin property to Performance interface. |
| Frame Timing | Draft | Adds PerformanceFrameTiming interface. |
| Navigation Timing | Recommendation | Adds the PerformanceTiming and PerformanceNavigation interfaces. Adds timing and navigation properties to the Performance interface. |
| Navigation Timing Level 2 | Working Draft | Adds the PerformanceNavigationTiming interface. Obsolete's the the PerformanceTiming interface, the PerformanceNavigation interface, as well as the timing and navigation properties to the Performance interface. |
| Performance Timeline | Recommendation | Adds the PerformanceEntry interface, the PerformanceEntryList type, as well as the getEntries(), getEntriesByType(), and getEntriesByName() methods on the Performance interface. |
| Performance Timeline Level 2 | Candidate Recommendation | Adds serializer to the PerformanceEntry interface as well as adding the PerformanceObserver interface and callback |
| Resource Timing Level 1 | Candidate Recommendation | Adds the PerformanceResourceTiming interface. Adds the clearResourceTimings() method, the setResourceTimingBufferSize() method, and the onresourcetimingbufferfull event handler to the Performance interface. Also adds the Timing-Allow-Origin response header. |
| Resource Timing Level 2 | Working Draft | Adds the nextHopProtocol, workerStart, transferSize, encodedBodySize, and decodedBodySize properties to the PerformanceResourceTiming interface. |
| Resource Timing Level 3 | Editor's Draft | |
| User Timing | Recommendation | Adds mark(), clearMarks(), measure() and clearMeasures() methods to the Performance interface. Adds the PerformanceMark and PeformanceMeasure interfaces. |
| User Timing Level 2 | Working Draft |
As shown in the Performance interface's Browser Compatibility table, most of these interfaces are broadly implemented by desktop browsers.
To test your browser's support for the Performance interface, run the perf-api-support application.
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Performance_API