Performance: clearMarks() 方法
注意:此功能在 Web Workers 中可用。
clearMarks() 方法会从浏览器的性能时间线上移除所有或特定的 PerformanceMark 对象。
语法
js
clearMarks()
clearMarks(name)
参数
name可选-
一个表示
PerformanceMark对象name的字符串。如果省略此参数,则会移除所有entryType为"mark"的条目。
返回值
无(undefined)。
示例
移除标记
要清理所有性能标记,或仅清理特定条目,请像这样使用 clearMarks() 方法:
js
// Create a bunch of marks
performance.mark("login-started");
performance.mark("login-started");
performance.mark("login-finished");
performance.mark("form-sent");
performance.mark("video-loaded");
performance.mark("video-loaded");
performance.getEntriesByType("mark").length; // 6
// Delete just the "login-started" mark entries
performance.clearMarks("login-started");
performance.getEntriesByType("mark").length; // 4
// Delete all of the mark entries
performance.clearMarks();
performance.getEntriesByType("mark").length; // 0
规范
| 规范 |
|---|
| 用户计时 # dom-performance-clearmarks |
浏览器兼容性
加载中…