aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/performanceobserver/index.html
blob: 16b1f768d819d1b91ac7ca23fad30555fcc364bc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
---
title: 性能监测对象
slug: Web/API/PerformanceObserver
tags:
  - API
  - 性能
  - 性能记录
  - 接口
translation_of: Web/API/PerformanceObserver
---
<div>{{APIRef("Performance Timeline API")}}</div>

<div><strong><code>PerformanceObserver</code></strong> 用于监测性能度量事件,在浏览器的性能时间轴记录下一个新的 {{domxref("PerformanceEntry","performance entries", '', 'true')}}  的时候将会被通知 。</div>

<div></div>

<div>{{AvailableInWorkers}}</div>

<h2 id="构造函数">构造函数</h2>

<dl>
 <dt>{{domxref("PerformanceObserver.PerformanceObserver","PerformanceObserver()")}}</dt>
 <dd>创建并返回一个新的 <code>PerformanceObserver</code> 对象。</dd>
</dl>

<h2 id="方法">方法</h2>

<dl>
 <dt>{{domxref("PerformanceObserver.observe","PerformanceObserver.observe()")}}</dt>
 <dd>指定监测的 {{domxref("PerformanceEntry.entryType","entry types")}} 的集合。 当 {{domxref("PerformanceEntry","performance entry")}} 被记录并且是指定的 <code>entryTypes</code> 之一的时候,性能观察者对象的回调函数会被调用。</dd>
 <dt>{{domxref("PerformanceObserver.disconnect","PerformanceObserver.disconnect()")}}</dt>
 <dd>性能监测回调停止接收 {{domxref("PerformanceEntry","性能条目", '', 'true')}}</dd>
</dl>

<dl>
</dl>

<h2 id="示例">示例</h2>

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

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">规范草案</th>
   <th scope="col">状态</th>
   <th scope="col">注释</th>
  </tr>
  <tr>
   <td>{{SpecName('Performance Timeline Level 2', '#dom-performanceobserver', 'PerformanceObserver')}}</td>
   <td>{{Spec2('Performance Timeline Level 2')}}</td>
   <td><code>PerformanceObserver</code> 接口的初始定义</td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

<div>


<p>{{Compat("api.PerformanceObserver")}}</p>
</div>