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 |
瀏覽器相容性
載入中…