Performance.clearMarks()
clearMarks()
这个方法可以从浏览器的performance entry 缓存中移除声明的标记。如果调用这个方法时没有传递参数, 则所有带有entry type
这类标记的performance entries
将从 performance entry 缓存区中被移除。
用法
performance.clearMarks(); performance.clearMarks(name);
参数
- name 可选
DOMString
表示时间戳的名字,如果没有提供这个参数, 则所有带有entry type
这类标记的performance entries
将从 performance entry 缓存区中被移除。
返回值
- void
例子
下面的例子演示clearMarks() 的两种用法。
function clear_mark(name) {
if (performance.clearMarks === undefined) {
console.log("performance.clearMarks Not supported");
return;
}
//移除所有标记了此名称的peformance entry
performance.clearMarks(name);
}
function clear_all_marks() {
if (performance.clearMarks === undefined) {
console.log("performance.clearMarks Not supported");
return;
}
//从performance 缓冲区中移除所有标记的performance entry
performance.clearMarks();
}
说明
说明 | 状态 | 备注 |
---|---|---|
User Timing Level 2 clearMarks() |
Working Draft | Clarifies clearMarks() . |
User Timing clearMarks() |
Recommendation | Basic definition. |
浏览器兼容性
BCD tables only load in the browser