This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

mark

Summary

Stores a timestamp with the associated name (a “mark”).

Method of apis/user_timing/Performanceapis/user_timing/Performance

Syntax

 object.mark(markName);

Parameters

markName

Data-type
any

Name associated with the performance mark.

Return Value

No return value

Examples

// set begin mark
performance.mark("startMark");
// execute a function to be measured
someFunction();
// set end mark
performance.mark("stopMark");

// save the timing information
performance.measure("functionTime", "startMark", "stopMark");
// display the measured time
var measures = performance.getEntriesByType("measure");
alert("functionTime: " + measures[0].duration);

// clear the measure "functionTime"
performance.clearMeasures("functionTime");
// clear all marks
performance.clearMarks();

Notes

Names for custom performance marks cannot duplicate the names of built-in performance marks.

When mark names are reused, the previous timing values are replaced by the later timing values.

Related specifications

W3C User Timing Specification
W3C Recommendation

Attributions