Performance

Performance interface provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the 性能时间线 API Navigation Timing API User Timing API ,和 资源计时 API .

An object of this type can be obtained by calling the window.performance read-only attribute.

注意 : This interface and its members are available in Web 工作者 , except where indicated below. Also, note that performance markers and measures are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.

特性

Performance interface doesn't inherit any properties.

Performance.navigation 只读
A legacy PerformanceNavigation object that provides useful context about the operations included in the times listed in timing , including whether the page was a load or a refresh, how many redirections occurred, and so forth. Not available in workers.
Performance.timing 只读
A legacy PerformanceTiming object containing latency-related performance information. Not available in workers.
Performance.memory 只读
A non-standard extension added in Chrome, this property provides an object with basic memory usage information. You should not use this non-standard API.
Performance.timeOrigin 只读
Returns the high resolution timestamp of the start time of the performance measurement.

方法

Performance interface doesn't inherit any methods .

Performance.clearMarks()
移除给定 mark from the browser's performance entry buffer.
Performance.clearMeasures()
移除给定 measure from the browser's performance entry buffer.
Performance.clearResourceTimings()
Removes all performance entries 采用 entryType of " resource " from the browser's performance data buffer.
Performance.getEntries()
Returns a list of PerformanceEntry objects based on the given filter .
Performance.getEntriesByName()
Returns a list of PerformanceEntry objects based on the given name and entry type .
Performance.getEntriesByType()
Returns a list of PerformanceEntry objects of the given entry type .
Performance.mark()
创建 timestamp in the browser's performance entry buffer with the given name.
Performance.measure()
Creates a named timestamp in the browser's performance entry buffer between two specified marks (known as the start mark and end mark , respectively).
Performance.now()
返回 DOMHighResTimeStamp representing the number of milliseconds elapsed since a reference instant.
Performance.setResourceTimingBufferSize()
Sets the browser's resource timing buffer size to the specified number of " resource " type performance entry 对象。
Performance.toJSON()
Is a jsonizer returning a json object representing the Performance 对象。

Events

监听这些事件使用 addEventListener() 或通过把事件监听器赋值给 on eventname 特性为此接口。

resourcetimingbufferfull
Fired when the browser's resource timing buffer is full.
Also available via the onresourcetimingbufferfull 特性。

规范

规范 状态 Comment
High Resolution Time Level 2
The definition of 'Performance' in that specification.
Recommendation Defines toJson() 方法。
高分辨率时间
The definition of 'Performance' in that specification.
Recommendation Defines now() 方法。
Performance Timeline Level 2
The definition of 'Performance extensions' in that specification.
候选推荐 变化 getEntries() 接口。
性能时间线
The definition of 'Performance extensions' in that specification.
Recommendation Defines getEntries() , getEntriesByType() and getEntriesByName() 方法。
Resource Timing Level 1
The definition of 'Performance extensions' in that specification.
候选推荐 Defines clearResourceTimings() and setResourceTimingBufferSize() methods and the onresourcetimingbufferfull 特性。
User Timing Level 2
The definition of 'Performance extensions' in that specification.
工作草案 Clarifies mark() , clearMark() , measure() and clearMeasure() 方法。
User Timing
The definition of 'Performance extensions' in that specification.
Recommendation Defines mark() , clearMark() , measure() and clearMeasure() 方法。

浏览器兼容性

更新 GitHub 上的兼容性数据
Desktop Mobile
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
Performance Chrome 6 Edge 12 Firefox 7 IE 9 Opera 15 Safari 8 WebView Android 1 Chrome Android 18 Firefox Android 7 Opera Android 14 Safari iOS 9 Samsung Internet Android 1.0
clearMarks Chrome 29
29
25 — 29
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 41 IE 10 Opera 33 Safari 11 WebView Android ≤37
≤37
≤37 — ≤37
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 29
29
25 — 29
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 42 Opera Android 33 Safari iOS 11 Samsung Internet Android 2.0
2.0
1.5 — 2.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
clearMeasures Chrome 29
29
25 — 29
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 41 IE 10 Opera 33 Safari 11 WebView Android Yes Chrome Android 29
29
25 — 29
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 42 Opera Android 33 Safari iOS 11 Samsung Internet Android 2.0
2.0
1.5 — 2.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
clearResourceTimings Chrome 46
46
22 — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE Yes Opera Yes Safari 11 WebView Android 46
46
? — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 46
46
25 — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Yes Opera Android Yes Safari iOS 11 Samsung Internet Android 5.0
5.0
1.5 — 7.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
getEntries Chrome 28
28
25 — 36
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE Yes Opera 不支持 No Safari 11 WebView Android Yes Chrome Android 28
28
25 — 36
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 25 Opera Android 不支持 No Safari iOS 11 Samsung Internet Android 1.5
1.5
1.5 — 3.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
getEntriesByName Chrome 28
28
25 — 36
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE Yes Opera 不支持 No Safari 11 WebView Android Yes Chrome Android 28
28
25 — 36
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 25 Opera Android 不支持 No Safari iOS 11 Samsung Internet Android 1.5
1.5
1.5 — 3.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
getEntriesByType Chrome 28
28
25 — 36
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE Yes Opera 15
15
15 — 23
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari 11 WebView Android Yes Chrome Android 28
28
25 — 36
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 25 Opera Android 15
15
14 — 24
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Safari iOS 11 Samsung Internet Android 1.5
1.5
1.5 — 3.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
mark Chrome 28
28
25 — 28
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 41 IE 10 Opera 33 Safari 11 WebView Android Yes Chrome Android 28
28
25 — 28
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 42 Opera Android 33 Safari iOS 11 Samsung Internet Android 1.5
measure Chrome 28
28
25 — 28
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 41 IE 10 Opera 33 Safari 11 WebView Android 46 Chrome Android 28
28
25 — 28
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android 42 Opera Android 33 Safari iOS 11 Samsung Internet Android 1.5
memory
非标
Chrome 7 Edge ≤79 Firefox 不支持 No IE ? Opera Yes Safari 不支持 No WebView Android Yes Chrome Android 18 Firefox Android 不支持 No Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 1.0
navigation
弃用
Chrome 10 Edge 12 Firefox 7 IE 9 Opera 15 Safari 8 WebView Android Yes Chrome Android 18 Firefox Android 7 Opera Android 不支持 No Safari iOS 9 Samsung Internet Android 1.0
now Chrome 24
24
21 — 24
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox 15
注意事项
15
注意事项
In Firefox 57.0.4 the accuracy was reduced to 20 microseconds.
In Firefox 59 the accuracy was reduced to 2 milliseconds.
In Firefox 60 the accuracy was increased to 1 millisecond.
IE 10 Opera 15 Safari 8 WebView Android Yes Chrome Android 25 Firefox Android 15
注意事项
15
注意事项
In Firefox 57.0.4 the accuracy was reduced to 20 microseconds.
In Firefox 59 the accuracy was reduced to 2 milliseconds.
In Firefox 60 the accuracy was increased to 1 millisecond.
Opera Android 14 Safari iOS 9 Samsung Internet Android 1.5
onresourcetimingbufferfull Chrome 46
46
22 — 57
Alternate Name
Alternate Name Uses the non-standard name: onwebkitresourcetimingbufferfull
Edge ≤79 Firefox Yes IE 不支持 No Opera 不支持 No Safari 11 WebView Android 46
46
? — 57
Alternate Name
Alternate Name Uses the non-standard name: onwebkitresourcetimingbufferfull
Chrome Android 46
46
25 — 57
Alternate Name
Alternate Name Uses the non-standard name: onwebkitresourcetimingbufferfull
Firefox Android Yes Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 5.0
5.0
1.5 — 7.0
Alternate Name
Alternate Name Uses the non-standard name: onwebkitresourcetimingbufferfull
resourcetimingbufferfull event Chrome 46
46
22 — 57
Alternate Name
Alternate Name Uses the non-standard name: webkitresourcetimingbufferfull
Edge ≤79 Firefox Yes IE 不支持 No Opera 不支持 No Safari 11 WebView Android 46
46
? — 57
Alternate Name
Alternate Name Uses the non-standard name: webkitresourcetimingbufferfull
Chrome Android 46
46
25 — 57
Alternate Name
Alternate Name Uses the non-standard name: webkitresourcetimingbufferfull
Firefox Android Yes Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 5.0
5.0
1.5 — 7.0
Alternate Name
Alternate Name Uses the non-standard name: webkitresourcetimingbufferfull
setResourceTimingBufferSize Chrome 46
46
22 — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge 12 Firefox Yes IE Yes Opera Yes Safari 11 WebView Android 46
46
? — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Chrome Android 46
46
25 — 57
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Firefox Android Yes Opera Android Yes Safari iOS 不支持 No Samsung Internet Android 5.0
5.0
1.5 — 7.0
Prefixed
Prefixed Implemented with the vendor prefix: webkit
timeOrigin
Chrome 62 Edge 16 Firefox 53 IE ? Opera 49 Safari 不支持 No WebView Android 62 Chrome Android 62 Firefox Android 53 Opera Android 46 Safari iOS 不支持 No Samsung Internet Android 8.0
timing
弃用
Chrome 6 Edge 12 Firefox 7 IE 9 Opera 15 Safari 8 WebView Android Yes Chrome Android 18 Firefox Android 7 Opera Android 14 Safari iOS 9 Samsung Internet Android 1.0
toJSON Chrome 56 Edge 12 Firefox 25 IE ? Opera 不支持 No Safari 不支持 No WebView Android 56 Chrome Android 56 Firefox Android 25 Opera Android 不支持 No Safari iOS 不支持 No Samsung Internet Android 6.0

图例

完整支持
完整支持
不支持
不支持
兼容性未知
兼容性未知
实验。期望将来行为有所改变。
实验。期望将来行为有所改变。
非标。预期跨浏览器支持较差。
弃用。不要用于新网站。
弃用。不要用于新网站。
见实现注意事项。
使用非标名称。
使用非标名称。
要求使用供应商前缀或不同名称。
要求使用供应商前缀或不同名称。