aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/performanceentry/index.html
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/performanceentry/index.html
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/performanceentry/index.html')
-rw-r--r--files/zh-cn/web/api/performanceentry/index.html101
1 files changed, 101 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/performanceentry/index.html b/files/zh-cn/web/api/performanceentry/index.html
new file mode 100644
index 0000000000..c0fde6ee9d
--- /dev/null
+++ b/files/zh-cn/web/api/performanceentry/index.html
@@ -0,0 +1,101 @@
+---
+title: PerformanceEntry
+slug: Web/API/PerformanceEntry
+tags:
+ - API
+ - Interface
+ - NeedsTranslation
+ - Reference
+ - TopicStub
+ - Web Performance
+translation_of: Web/API/PerformanceEntry
+---
+<div>{{APIRef("Performance Timeline API")}}</div>
+
+<p><strong><code>PerformanceEntry</code></strong> 对象代表了 performance 时间列表中的单个 metric 数据. 每一个 <em>performance entry 都可以在应用运行过程中通过手动构建 </em><em>{{domxref("PerformanceMark","mark")}}</em> 或者 <em>{{domxref("PerformanceMeasure","measure")}}</em> (例如调用 {{domxref("Performance.mark","mark()")}} 方法) 生成. 此外, Performance entries 在资源加载的时候,也会被动生成(例如图片、script、css等资源加载)</p>
+
+<p class="note">Note: Performance 对象暴露给了 {{domxref("Window")}} 和 {{domxref("Worker")}}. 同时该对象扩展了几个其他对象的属性,包括 {{domxref("PerformanceMark")}}, {{domxref("PerformanceMeasure")}}, {{domxref("PerformanceFrameTiming")}}, {{domxref("PerformanceNavigationTiming")}} 以及 {{domxref("PerformanceResourceTiming")}}.</p>
+
+<h2 id="Properties">Properties</h2>
+
+<dl>
+ <dt>{{domxref("PerformanceEntry.name")}} {{readonlyInline}}</dt>
+ <dd>{{domxref("DOMString")}} 该 performance entry 的名字</dd>
+ <dt>{{domxref("PerformanceEntry.entryType")}} {{readonlyInline}}</dt>
+ <dd>{{domxref("DOMString")}} 代表所上报的 performance metric 的 entryType 类型,例如 "mark". 可以通过 {{domxref("PerformanceEntry.entryType","entryType")}} 查阅完整的 entryType type 类型.</dd>
+ <dt>{{domxref("PerformanceEntry.startTime")}} {{readonlyInline}}</dt>
+ <dd> {{domxref("DOMHighResTimeStamp")}}  此为 metric 上报时的时间</dd>
+ <dt>{{domxref("PerformanceEntry.duration")}} {{readonlyInline}}</dt>
+ <dd>{{domxref("DOMHighResTimeStamp")}} 该事件的耗时</dd>
+</dl>
+
+<h2 id="Methods">Methods</h2>
+
+<dl>
+ <dt>{{domxref("PerformanceEntry.toJSON","PerformanceEntry.toJSON()")}}</dt>
+ <dd>返回 <code>PerformanceEntry</code> 对象的 JSON 格式数据</dd>
+ <dd> </dd>
+</dl>
+
+<h2 id="Example">Example</h2>
+
+<p>以下例子检查了当前浏览器所支持的所有 <code>PerformanceEntry</code> 属性,每个属性的检查结果都会通过 console 打印出来</p>
+
+<pre class="brush: js">function print_PerformanceEntries() {
+ // Use getEntries() to get a list of all performance entries
+ var p = performance.getEntries();
+ for (var i=0; i &lt; p.length; i++) {
+ console.log("PerformanceEntry[" + i + "]");
+ print_PerformanceEntry(p[i]);
+ }
+}
+function print_PerformanceEntry(perfEntry) {
+ var properties = ["name",
+ "entryType",
+ "startTime",
+ "duration"];
+
+ for (var i=0; i &lt; properties.length; i++) {
+ // check each property
+ var supported = properties[i] in perfEntry;
+ if (supported) {
+ var value = perfEntry[properties[i]];
+ console.log("... " + properties[i] + " = " + value);
+ } else {
+ console.log("... " + properties[i] + " = NOT supported");
+ }
+ }
+}
+</pre>
+
+<h2 id="Specifications">Specifications</h2>
+
+<table class="standard-table">
+ <tbody>
+ <tr>
+ <th scope="col">Specification</th>
+ <th scope="col">Status</th>
+ <th scope="col">Comment</th>
+ </tr>
+ <tr>
+ <td>{{SpecName('Performance Timeline Level 2', '#dom-performanceentry', 'PerformanceEntry')}}</td>
+ <td>{{Spec2('Performance Timeline Level 2')}}</td>
+ <td>Added <code>toJSON()</code> serializer method.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('Performance Timeline', '#dom-performanceentry', 'PerformanceEntry')}}</td>
+ <td>{{Spec2('Performance Timeline')}}</td>
+ <td>Initial definition.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="Browser_compatibility">Browser compatibility</h2>
+
+<div>
+<div>
+
+
+<p>{{Compat("api.PerformanceEntry")}}</p>
+</div>
+</div>