Performance - Web APIs 编辑

The Performance interface provides access to performance-related information for the current page. It's part of the High Resolution Time API, but is enhanced by the Performance Timeline API, the Navigation Timing API, the User Timing API, and the Resource Timing API.

An object of this type can be obtained by calling the window.performance read-only attribute.

Note: This interface and its members are available in Web Workers via WorkerGlobalScope.performance , except where indicated below. Also, note that performance markers and measures are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.

Properties

The Performance interface doesn't inherit any properties.

Performance.navigation Read only  This deprecated API should no longer be used, but will probably still work.
A legacy PerformanceNavigation object that provides useful context about the operations included in the times listed in timing, including whether the page was a load or a refresh, how many redirections occurred, and so forth.

Not available in workers.

Performance.timing Read only  This deprecated API should no longer be used, but will probably still work.
A legacy PerformanceTiming object containing latency-related performance information.

Not available in workers.

Performance.memory Read only This API has not been standardized.
A non-standard extension added in Chrome, this property provides an object with basic memory usage information. You should not use this non-standard API.
Performance.timeOrigin Read only  This API has not been standardized.
Returns the high resolution timestamp of the start time of the performance measurement.

Methods

The Performance interface doesn't inherit any methods.

Performance.clearMarks()
Removes the given mark from the browser's performance entry buffer.
Performance.clearMeasures()
Removes the given measure from the browser's performance entry buffer.
Performance.clearResourceTimings()
Removes all performance entries with a entryType of "resource" from the browser's performance data buffer.
Performance.getEntries()
Returns a list of PerformanceEntry objects based on the given filter.
Performance.getEntriesByName()
Returns a list of PerformanceEntry objects based on the given name and entry type.
Performance.getEntriesByType()
Returns a list of PerformanceEntry objects of the given entry type.
Performance.mark()
Creates a timestamp in the browser's performance entry buffer with the given name.
Performance.measure()
Creates a named timestamp in the browser's performance entry buffer between two specified marks (known as the start mark and end mark, respectively).
Performance.now()
Returns a DOMHighResTimeStamp representing the number of milliseconds elapsed since a reference instant.
Performance.setResourceTimingBufferSize()
Sets the browser's resource timing buffer size to the specified number of "resource" type performance entry objects.
Performance.toJSON()
Is a jsonizer returning a json object representing the Performance object.

Events

Listen to these events using addEventListener() or by assigning an event listener to the oneventname property of this interface.

resourcetimingbufferfull
Fired when the browser's resource timing buffer is full.
Also available via the onresourcetimingbufferfull property.

Specifications

SpecificationStatusComment
High Resolution Time Level 2
The definition of 'Performance' in that specification.
RecommendationDefines toJson() method.
High Resolution Time
The definition of 'Performance' in that specification.
RecommendationDefines now() method.
Performance Timeline Level 2
The definition of 'Performance extensions' in that specification.
Candidate RecommendationChanges getEntries() interface.
Performance Timeline
The definition of 'Performance extensions' in that specification.
RecommendationDefines getEntries(), getEntriesByType() and getEntriesByName() methods.
Resource Timing Level 1
The definition of 'Performance extensions' in that specification.
Candidate RecommendationDefines clearResourceTimings() and setResourceTimingBufferSize() methods and the onresourcetimingbufferfull property.
User Timing Level 2
The definition of 'Performance extensions' in that specification.
Working DraftClarifies mark(), clearMark(), measure() and clearMeasure() methods.
User Timing
The definition of 'Performance extensions' in that specification.
RecommendationDefines mark(), clearMark(), measure() and clearMeasure() methods.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:57 次

字数:12649

最后编辑:7年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文