diff options
Diffstat (limited to 'files/zh-cn/web/api/performance/index.html')
| -rw-r--r-- | files/zh-cn/web/api/performance/index.html | 133 |
1 files changed, 133 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/performance/index.html b/files/zh-cn/web/api/performance/index.html new file mode 100644 index 0000000000..a88936f95b --- /dev/null +++ b/files/zh-cn/web/api/performance/index.html @@ -0,0 +1,133 @@ +--- +title: Performance +slug: Web/API/Performance +tags: + - API + - Interface + - Performance + - Web Performance +translation_of: Web/API/Performance +--- +<div>{{APIRef("High Resolution Time")}}</div> + +<p><strong><code>Performance</code></strong> 接口可以获取到当前页面中与性能相关的信息。它是 High Resolution Time API 的一部分,同时也融合了 Performance Timeline API、<a href="https://developer.mozilla.org/en-US/docs/Web/API/Navigation_timing_API">Navigation Timing API</a>、 <a href="https://developer.mozilla.org/en-US/docs/Web/API/User_Timing_API">User Timing API</a> 和 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Resource_Timing_API">Resource Timing API</a>。</p> + +<p>该类型的对象可以通过调用只读属性 {{domxref("Window.performance")}} 来获得。</p> + +<div class="note"> +<p><strong>注意:</strong>除了以下指出的情况外,该接口及其成员在 {{domxref("Web Worker")}} 中可用。此外,还需注意,performance 的创建和衡量都是同一环境下的。即,如果你在主线程(或者其他 worker)中创建了一个 performance,那么它在另外的 worker 线程中是不可用的;反之亦然。</p> +</div> + +<h2 id="属性">属性</h2> + +<p><em><code>Performance</code> 接口没有继承任何属性。</em></p> + +<dl> + <dt>{{deprecated_inline}}{{domxref("Performance.navigation")}} {{readonlyInline}}</dt> + <dd>{{domxref("PerformanceNavigation")}} 对象提供了在指定的时间段里发生的操作相关信息,包括页面是加载还是刷新、发生了多少次重定向等等。Not available in workers.</dd> + <dt>{{deprecated_inline}}{{domxref("Performance.timing")}} {{readonlyInline}}</dt> + <dd>{{domxref("PerformanceTiming")}} 对象包含延迟相关的性能信息。Not available in workers.</dd> + <dt>{{domxref("Performance.memory", "performance.memory")}} {{Non-standard_inline}}</dt> + <dd>其是 Chrome 添加的一个非标准扩展,这个属性提供了一个可以获取到基本内存使用情况的对象。<strong>不应该</strong>使用这个非标准的 API。</dd> + <dt>{{domxref("Performance.timeOrigin")}} {{readonlyInline}} {{Non-standard_inline}}</dt> + <dd>返回性能测量开始时的时间的高精度时间戳。</dd> + <dt> + <h3 id="事件处理程序">事件处理程序</h3> + </dt> + <dt>{{domxref("Performance.onresourcetimingbufferfull")}}</dt> + <dd>一个回调的 {{domxref("EventTarget")}},当触发 {{event("resourcetimingbufferfull")}} 事件的时候会被调用。</dd> +</dl> + +<h2 id="方法">方法</h2> + +<p><em><em><code>Performance</code> 接口没有继承任何方法。</em></em></p> + +<dl> + <dt>{{domxref("Performance.clearMarks()")}}</dt> + <dd>将给定的 mark 从浏览器的性能输入缓冲区中移除。</dd> + <dt>{{domxref("Performance.clearMeasures()")}}</dt> + <dd>将给定的 measure 从浏览器的性能输入缓冲区中移除。</dd> + <dt>{{domxref("Performance.clearResourceTimings()")}}</dt> + <dd>从浏览器的性能数据缓冲区中移除所有 {{domxref("PerformanceEntry.entryType","entryType")}} 是 "<code>resource</code>" 的 {{domxref("PerformanceEntry","performance entries")}}。</dd> + <dt>{{domxref("Performance.getEntries()")}}</dt> + <dd>基于给定的 <em>filter </em>返回一个 {{domxref("PerformanceEntry")}} 对象的列表。</dd> + <dt>{{domxref("Performance.getEntriesByName()")}}</dt> + <dd>基于给定的 <em>name </em>和 <em>entry type </em>返回一个 {{domxref("PerformanceEntry")}} 对象的列表。</dd> + <dt>{{domxref("Performance.getEntriesByType()")}}</dt> + <dd>基于给定的 <em>entry type </em>返回一个 {{domxref("PerformanceEntry")}} 对象的列表</dd> + <dt>{{domxref("Performance.mark()")}}</dt> + <dd>根据给出 name 值,在浏览器的性能输入缓冲区中创建一个相关的{{domxref("DOMHighResTimeStamp","timestamp")}}</dd> + <dt>{{domxref("Performance.measure()")}}</dt> + <dd>在浏览器的指定 <em>start mark 和 end mark</em> 间的性能输入缓冲区中创建一个指定的 {{domxref("DOMHighResTimeStamp","timestamp")}}</dd> + <dt>{{domxref("Performance.now()")}}</dt> + <dd>返回一个表示从性能测量时刻开始经过的毫秒数 {{domxref("DOMHighResTimeStamp")}}</dd> + <dt>{{domxref("Performance.setResourceTimingBufferSize()")}}</dt> + <dd>将浏览器的资源 timing 缓冲区的大小设置为 "<code>resource</code>" {{domxref("PerformanceEntry.entryType","type")}} {{domxref("PerformanceEntry","performance entry")}} 对象的指定数量</dd> + <dt>{{domxref("Performance.toJSON()")}}</dt> + <dd>其是一个 JSON 格式转化器,返回 <code>Performance</code> 对象的 JSON 对象</dd> +</dl> + +<h2 id="规范">规范</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('Highres Time Level 3', '#dom-performance-timeorigin','timeOrigin')}}</td> + <td>{{Spec2('Highres Time Level 3')}}</td> + <td>Defines <code>timeOrigin</code> property.</td> + </tr> + <tr> + <td>{{SpecName('Highres Time Level 2', '#the-performance-interface', 'toJSON()')}}</td> + <td>{{Spec2('Highres Time Level 2')}}</td> + <td>Defines <code>toJson()</code> method.</td> + </tr> + <tr> + <td>{{SpecName('Highres Time', '#the-performance-interface', 'Performance')}}</td> + <td>{{Spec2('Highres Time')}}</td> + <td>Defines <code>now()</code> method.</td> + </tr> + <tr> + <td>{{SpecName('Navigation Timing', '#sec-window.performance-attribute', 'Performance')}}</td> + <td>{{Spec2('Navigation Timing')}}</td> + <td>Defines <code>timing</code> and <code>navigation</code> properties.</td> + </tr> + <tr> + <td>{{SpecName('Performance Timeline Level 2', '#extensions-to-the-performance-interface', 'Performance extensions')}}</td> + <td>{{Spec2('Performance Timeline Level 2')}}</td> + <td>Changes <code>getEntries()</code> interface.</td> + </tr> + <tr> + <td>{{SpecName('Performance Timeline', '#sec-window.performance-attribute', 'Performance extensions')}}</td> + <td>{{Spec2('Performance Timeline')}}</td> + <td>Defines <code>getEntries()</code>, <code>getEntriesByType()</code> and <code>getEntriesByName()</code> methods.</td> + </tr> + <tr> + <td>{{SpecName('Resource Timing', '#extensions-performance-interface', 'Performance extensions')}}</td> + <td>{{Spec2('Resource Timing')}}</td> + <td>Defines <code>clearResourceTimings()</code> and <code>setResourceTimingBufferSize()</code> methods and the <code>onresourcetimingbufferfull</code> property.</td> + </tr> + <tr> + <td>{{SpecName('User Timing Level 2', '#extensions-performance-interface', 'Performance extensions')}}</td> + <td>{{Spec2('User Timing Level 2')}}</td> + <td>Clarifies <code>mark()</code>, <code>clearMark()</code>, <code>measure()</code> and <code>clearMeasure()</code> methods.</td> + </tr> + <tr> + <td>{{SpecName('User Timing', '#extensions-performance-interface', 'Performance extensions')}}</td> + <td>{{Spec2('User Timing')}}</td> + <td>Defines <code>mark()</code>, <code>clearMark()</code>, <code>measure()</code> and <code>clearMeasure()</code> methods.</td> + </tr> + </tbody> +</table> + +<h2 id="浏览器兼容性">浏览器兼容性</h2> + +<div class="hidden"> +<p>The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> +</div> + +<p>{{Compat("api.Performance")}}</p> |
