Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / JavaScript

performance.measure — named time intervals

performance.measure records a named interval on the performance timeline. It can use marks or explicit timestamps; the modern overload returns a PerformanceMeasure containing the interval's start and duration in milliseconds.

Version: ECMAScript and Web APIs; exact feature edition and browser support reviewed per entry; Node 24 in repository does not prove browser API support

Syntax

performance.measure(name)
performance.measure(name, startMark, endMark)
performance.measure(name, { start, end, detail })
performance.measure(name, { start, duration, detail })
performance.measure(name, { end, duration, detail })

performance.measure belongs to the User Timing Web API, not ECMAScript. It records an entry of type "measure"; the modern overload returns a PerformanceMeasure with name, startTime, duration, and detail. It does not execute or automatically time a supplied function.

performance.measure(name) covers the interval from performance timeline zero to the call. The mark-name overload uses the latest matching performance.mark. The options object accepts start and end as mark names or millisecond timestamps relative to the performance time origin, not the Unix epoch. You may supply start with duration, or end with duration, but not all three fields together.

An empty options object is allowed. A nonempty one requires start or end and excludes a third argument; violating these rules throws TypeError. A missing ordinary named mark throws SyntaxError. A negative input timestamp throws TypeError, but the resulting duration can be negative. detail is copied using structured cloning.

The example uses synthetic timestamps: it demonstrates interval calculation, not a speed benchmark. performance.clearMeasures(name) removes stored measures with that name, but not marks. The options object and returned entry come from Level 3 extensions; Level 2 returned undefined. Neither the method's presence alone nor Node 24 proves support for this overload in a target browser.

Examples

(() => {
  const name = "cktis:measure-demo";
  try {
    const entry = performance.measure(name, { start: 10, end: 35 });
    console.log(`${entry.entryType}: ${entry.startTime} + ${entry.duration} ms`);
  } finally {
    performance.clearMeasures(name);
  }
})();

Result

measure: 10 + 25 ms

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources