性能监测对象

PerformanceObserver 用于监测性能度量事件,在浏览器的性能时间轴记录下一个新的 performance entries  的时候将会被通知 。
Note: 此特性在 Web Worker 中可用。

构造函数

PerformanceObserver()
创建并返回一个新的 PerformanceObserver 对象。

方法

PerformanceObserver.observe()
指定监测的 entry types 的集合。 当 performance entry 被记录并且是指定的 entryTypes 之一的时候,性能观察者对象的回调函数会被调用。
PerformanceObserver.disconnect()
性能监测回调停止接收 性能条目

示例

function perf_observer(list, observer) { 
   // Process the "measure" event
   // 处理 "measure" 事件 
} 
var observer2 = new PerformanceObserver(perf_observer); 
observer2.observe({entryTypes: ["measure"]});

规范

规范草案 状态 注释
Performance Timeline Level 2
PerformanceObserver
Candidate Recommendation PerformanceObserver 接口的初始定义

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
PerformanceObserverChrome Full support 52Edge ? Firefox Full support 57IE No support NoOpera Full support 39Safari Full support 11WebView Android Full support 52Chrome Android Full support 52Firefox Android Full support 57Opera Android Full support 41Safari iOS Full support 11Samsung Internet Android ?
PerformanceObserver() constructorChrome Full support 52Edge ? Firefox Full support 57IE No support NoOpera Full support 39Safari Full support 11WebView Android Full support 52Chrome Android Full support 52Firefox Android Full support 57Opera Android Full support 41Safari iOS Full support 11Samsung Internet Android ?
disconnectChrome Full support 52Edge ? Firefox Full support 57IE No support NoOpera Full support 39Safari Full support 11WebView Android Full support 52Chrome Android Full support 52Firefox Android Full support 57Opera Android Full support 41Safari iOS Full support 11Samsung Internet Android ?
observeChrome Full support 52Edge ? Firefox Full support 57IE No support NoOpera Full support 39Safari Full support 11WebView Android Full support 52Chrome Android Full support 52Firefox Android Full support 57Opera Android Full support 41Safari iOS Full support 11Samsung Internet Android ?
supportedEntryTypes
Experimental
Chrome Full support 73Edge ? Firefox ? IE No support NoOpera Full support YesSafari ? WebView Android Full support 73Chrome Android Full support 73Firefox Android ? Opera Android Full support YesSafari iOS ? Samsung Internet Android ?
takeRecords
Experimental
Chrome Full support 65Edge ? Firefox Full support 60IE No support NoOpera Full support YesSafari No support NoWebView Android Full support 65Chrome Android Full support 65Firefox Android Full support 60Opera Android Full support YesSafari iOS No support NoSamsung Internet Android ?
Available in workersChrome Full support 62Edge ? Firefox ? IE No support NoOpera Full support 49Safari ? WebView Android Full support 62Chrome Android Full support 62Firefox Android ? Opera Android Full support 46Safari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.