Movatterモバイル変換


[0]ホーム

URL:


  1. 面向开发者的 Web 技术
  2. Web API
  3. Performance

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in EnglishAlways switch to English

Performance

Baseline Widely available *

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2015年9月⁩.

* Some parts of this feature may have varying levels of support.

Performance 接口可用于获取当前页面中与性能相关的信息。

性能条目特定于执行上下文。你可以通过Window.performance 访问窗口中运行的代码的性能信息,通过WorkerGlobalScope.performance 访问 worker 中运行的代码的性能信息。

EventTarget Performance

实例属性

Performance 接口没有继承任何属性。

已弃用Performance.navigation只读

PerformanceNavigation 对象提供了在指定的时间段里发生的操作相关信息,包括页面是加载还是刷新、发生了多少次重定向等等。Not available in workers.

已弃用Performance.timing只读

PerformanceTiming 对象包含延迟相关的性能信息。Not available in workers.

performance.memory非标准

其是 Chrome 添加的一个非标准扩展,这个属性提供了一个可以获取到基本内存使用情况的对象。不应该使用这个非标准的 API。

Performance.timeOrigin只读非标准

返回性能测量开始时的时间的高精度时间戳。

实例方法

Performance 接口没有继承任何方法。

Performance.clearMarks()

将给定的 mark 从浏览器的性能输入缓冲区中移除。

Performance.clearMeasures()

将给定的 measure 从浏览器的性能输入缓冲区中移除。

Performance.clearResourceTimings()

从浏览器的性能数据缓冲区中移除所有entryType 是 "resource" 的performance entries

Performance.getEntries()

基于给定的filter 返回一个PerformanceEntry 对象的列表。

Performance.getEntriesByName()

基于给定的nameentry type 返回一个PerformanceEntry 对象的列表。

Performance.getEntriesByType()

基于给定的entry type 返回一个PerformanceEntry 对象的列表

Performance.mark()

根据给出 name 值,在浏览器的性能输入缓冲区中创建一个相关的timestamp

Performance.measure()

在浏览器的指定start mark 和 end mark 间的性能输入缓冲区中创建一个指定的timestamp

Performance.now()

返回一个表示从性能测量时刻开始经过的毫秒数DOMHighResTimeStamp

Performance.setResourceTimingBufferSize()

将浏览器的资源 timing 缓冲区的大小设置为 "resource"typeperformance entry 对象的指定数量

Performance.toJSON()

其是一个 JSON 格式转化器,返回Performance 对象的 JSON 对象

事件

使用addEventListener() 或者将事件监听器赋给该接口的oneventname 属性来监听这些事件。

resourcetimingbufferfull

在浏览器的资源计时缓冲区已满时触发。

规范

Specification
High Resolution Time
# sec-performance
Performance Timeline
# extensions-to-the-performance-interface
Resource Timing
# sec-extensions-performance-interface
User Timing
# extensions-performance-interface

浏览器兼容性

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp