Performance: clearMeasures() 方法
注意:此功能在 Web Workers 中可用。
clearMeasures() 方法会从浏览器的性能时间轴中移除所有或指定的 PerformanceMeasure 对象。
语法
js
clearMeasures()
clearMeasures(name)
参数
name可选-
一个代表
PerformanceMeasure对象name的字符串。如果省略此参数,则会移除所有entryType为"measure"的条目。
返回值
无(undefined)。
示例
移除测量
要清理所有性能测量,或仅清理特定条目,请按以下方式使用 clearMeasures() 方法:
js
// Create a bunch of measures
performance.measure("from navigation");
performance.mark("a");
performance.measure("from mark a", "a");
performance.measure("from navigation");
performance.measure("from mark a", "a");
performance.mark("b");
performance.measure("between a and b", "a", "b");
performance.getEntriesByType("measure").length; // 5
// Delete just the "from navigation" measure entries
performance.clearMeasures("from navigation");
performance.getEntriesByType("measure").length; // 3
// Delete all of the measure entries
performance.clearMeasures();
performance.getEntriesByType("measure").length; // 0
规范
| 规范 |
|---|
| 用户计时 # dom-performance-clearmeasures |
浏览器兼容性
加载中…