performance.clearMeasures()

The clearMeasures() method removes the named measure from the browser's performance entry buffer. If the method is called with no arguments, all performance entries with an entry type of "measure" will be removed from the performance entry buffer.

Note: This feature is available in Web Workers.

Syntax

performance.clearMeasures();
performance.clearMeasures(name);

Arguments

name Optional
A DOMString representing the name of the timestamp. If this argument is omitted, all performance entries with an entry type of "measure" will be removed.

Return value

void
 

Example

The following example shows both uses of the clearMeasures() method.

// Create a small helper to show how many PerformanceMeasure entries there are.
function logMeasureCount() {
  console.log(
    "Found this many entries: " + performance.getEntriesByType("measure").length
  );
}

// Create a bunch of measures.
performance.measure("from navigation");
performance.mark("a");
performance.measure("from mark a", "a");
performance.measure("from navigation");
performance.measure("from mark a", "a");
performance.mark("b");
performance.measure("between a and b", "a", "b");

logMeasureCount() // "Found this many entries: 5"

// Delete just the "from navigation" PerformanceMeasure entries.
performance.clearMeasures("from navigation");
logMeasureCount() // "Found this many entries: 3"

// Delete all of the PerformanceMeasure entries.
performance.clearMeasures();
logMeasureCount() // "Found this many entries: 0"

Specifications

Specification Status Comment
User Timing Level 2
The definition of 'clearMeasures()' in that specification.
Working Draft Clarifies clearMeasures().
User Timing
The definition of 'clearMeasures()' in that specification.
Recommendation Basic definition.

Browser compatibility

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidEdge MobileFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
clearMeasuresChrome Full support 29
Full support 29
No support 25 — 29
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Full support 12Firefox Full support 41IE Full support 10Opera Full support 33Safari Full support 11WebView Android Full support YesChrome Android Full support 29
Full support 29
No support 25 — 29
Prefixed
Prefixed Implemented with the vendor prefix: webkit
Edge Mobile Full support YesFirefox Android Full support 42Opera Android Full support 33Safari iOS Full support 11Samsung Internet Android ?

Legend

Full support  
Full support
Compatibility unknown  
Compatibility unknown
Requires a vendor prefix or different name for use.
Requires a vendor prefix or different name for use.

Document Tags and Contributors

Last updated by: gregtatum,