mark()
method creates a
timestamp
in the browser's
performance entry buffer
with the given name.
The application defined timestamp can be retrieved by one of the
性能
接口的
getEntries*()
methods (
getEntries()
,
getEntriesByName()
or
getEntriesByType()
).
mark()'s
stores its data internally as
PerformanceEntry
.
performance.mark(name);
DOMString
representing the name of the mark.
若
名称
given to this method already exists in the
PerformanceTiming
interface,
SyntaxError
is thrown.
The following example shows how to use
mark()
to create and retrieve
PerformanceMark
条目。
// Create a bunch of marks.
performance.mark("squirrel");
performance.mark("squirrel");
performance.mark("monkey");
performance.mark("monkey");
performance.mark("dog");
performance.mark("dog");
// Get all of the PerformanceMark entries.
const allEntries = performance.getEntriesByType("mark");
console.log(allEntries.length);
// 6
// Get all of the "monkey" PerformanceMark entries.
const monkeyEntries = performance.getEntriesByName("monkey");
console.log(monkeyEntries.length);
// 2
// Clear out all of the marks.
performance.clearMarks();
| 规范 | 状态 | 注释 |
|---|---|---|
|
User Timing Level 2
The definition of 'mark()' in that specification. |
工作草案 |
Clarifies
mark()
processing model.
|
|
User Timing
The definition of 'mark()' in that specification. |
推荐 | Basic definition. |
| 桌面 | 移动 | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
mark
|
Chrome
28
|
Edge 12 | Firefox 41 | IE 10 | Opera 33 | Safari 11 | WebView Android Yes |
Chrome Android
28
|
Firefox Android 42 | Opera Android 33 | Safari iOS 11 | Samsung Internet Android 1.5 |
完整支持
要求使用供应商前缀或不同名称。
性能