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.

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