Performance.mark()
The 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 Performance
interface's getEntries*()
methods (getEntries()
, getEntriesByName()
or getEntriesByType()
).
The mark's
performance entry
will have the following property values:
entryType
- set to "mark
".name
- set to the "name
" given when the mark was created.startTime
- set to thetimestamp
whenmark()
was called.duration
- set to "0
" (a mark has no duration).
If the name
given to this method already exists, SyntaxError
is thrown.
Syntax
JavaScript
Copy Code
performance.mark(name);
Arguments
- name
- A
DOMString
representing the name of the mark.
Return value
- void
Example
The following example shows how mark()
is used to create an application-defined peformance entry
in the browser's performance entry buffer.
JavaScript
Copy Code
function create_mark(name) { if (performance.mark === undefined) { console.log("performance.mark Not supported"); return; } // Create the performance mark performance.mark(name); }
Specifications
Specification | Status | Comment |
---|---|---|
User Timing The definition of 'mark()' in that specification. |
Editor's Draft | Clarifies mark() processing model. |
User Timing The definition of 'mark()' in that specification. |
Recommendation | Basic definition. |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari (WebKit) |
---|---|---|---|---|---|
Basic Support | 43.0 | 41 | 10 | 33 | No support |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | Firefox OS | IE Phone | Opera Mobile | Safari Mobile | Chrome for Android |
---|---|---|---|---|---|---|---|---|
Basic Support | No support | 46.0 | 42 | 42 | 10 | 33 | No support | 46.0 |
License
© 2016 Mozilla Contributors
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-us/docs/web/api/performance/mark