Performance.clearMarks()
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
clearMarks()
这个方法可以从浏览器的 performance entry 缓存中移除声明的标记。如果调用这个方法时没有传递参数,则所有带有entry type
这类标记的performance entries
将从 performance entry 缓存区中被移除。
语法
js
clearMarks()
clearMarks(name)
参数
- name 可选
-
DOMString
表示时间戳的名字,如果没有提供这个参数,则所有带有entry type
这类标记的performance entries
将从 performance entry 缓存区中被移除。
返回值
无
示例
下面的例子演示 clearMarks()
的两种用法。
js
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();
}
规范
Specification |
---|
User Timing # dom-performance-clearmarks |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
clearMarks |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- Requires a vendor prefix or different name for use.
- Has more compatibility info.
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.