duration
Summary
Returns a DOMHighResTimeStamp value. For marks, the value is always 0 (zero).
Property of apis/user_timing/PerformanceMarkapis/user_timing/PerformanceMark
Syntax
var result = element.duration;
element.duration = value;
Return Value
Returns an object of type
DOMHighResTimeStamp
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 first mark's data
var marks = performance.getEntriesByType("mark");
alert("Mark name: " + marks[0].name + "\n" +
"Mark type: " + marks[0].entryType + "\n" +
"Mark start: " + marks[0].startTime + "\n" +
"Mark duration: " + marks[0].duration);
// clear the measure "functionTime"
performance.clearMeasures("functionTime");
// clear all marks
performance.clearMarks();
Related specifications
- W3C User Timing Specification
- W3C Recommendation
Attributions
Microsoft Developer Network: Windows Internet Explorer API reference Article