The mark()
method creates a timestamp
in the browser's performance entry buffer with the given name.
The application defined timestamp can also be retrieved by one of the Performance
interface's getEntries*()
methods (getEntries()
, getEntriesByName()
or getEntriesByType()
).
The mark()'s
stores its data internally as PerformanceEntry
.
mark(name)
mark(name, markOptions)
The PerformanceMark
entry that was created.
The following example shows how to use mark()
to create and retrieve PerformanceMark
entries.
performance.mark("squirrel");
performance.mark("squirrel");
performance.mark("monkey");
performance.mark("monkey");
performance.mark("dog");
performance.mark("dog");
const allEntries = performance.getEntriesByType("mark");
console.log(allEntries.length);
const monkeyEntries = performance.getEntriesByName("monkey");
console.log(monkeyEntries.length);
performance.clearMarks();