Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 1103749 of Performance

  • Revision slug: Web/API/Performance
  • Revision title: Performance
  • Revision id: 1103749
  • Created:
  • Creator: jpmedley
  • Is current revision? No
  • Comment

Revision Content

{{APIRef("High Resolution Time")}}

The Performance interface represents timing-related performance information for the given page.

An object of this type can be obtained by calling the {{domxref("Window.performance")}} read-only attribute.

Note: This interface and its members are available in Web Workers, except where indicated below. Note that some available parts of the interface are not yet documented (see the Performance Timeline and User Timing specs for more details.) Also note that performance markers and measures are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.

Properties

The Performance interface doesn't inherit any properties.

{{domxref("Performance.navigation")}} {{readonlyInline}} {{NotAvailableInWorkerInline}}
Is a {{domxref("PerformanceNavigation")}} object representing the type of navigation that occurs in the given browsing context, like the amount of redirections needed to fetch the resource.
{{domxref("Performance.onresourcetimingbufferfull")}}
Is an {{domxref("EventTarget")}} which is a callback that will be called when the {{event("resourcetimingbufferfull")}} event is fired.
{{domxref("Performance.timing")}} {{readonlyInline}} {{NotAvailableInWorkerInline}}
Is a {{domxref("PerformanceTiming")}} object containing latency-related performance information.

Methods

The Performance interface doesn't inherit any method.

{{domxref("Performance.clearMarks()")}}
Removes the given mark from the browser's performance entry buffer.
{{domxref("Performance.clearMeasures()")}}
Removes the given measure from the browser's performance entry buffer.
{{domxref("Performance.clearResourceTimings()")}}
Removes all {{domxref("PerformanceEntry","performance entries")}} with a {{domxref("PerformanceEntry.entryType","entryType")}} of "resource" from the browser's performance data buffer.
{{domxref("Performance.getEntries()")}}
Returns a list of {{domxref("PerformanceEntry")}} objects based on the given filter.
{{domxref("Performance.getEntriesByName()")}}
Returns a list of {{domxref("PerformanceEntry")}} objects based on the given name and entry type.
{{domxref("Performance.getEntriesByType()")}}
Returns a list of {{domxref("PerformanceEntry")}} objects of the given entry type.
{{domxref("Performance.mark()")}}
Creates a {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's performance entry buffer with the given name.
{{domxref("Performance.measure()")}}
Creates a named {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's performance entry buffer between two specified marks (known as the start mark and end mark, respectively).
{{domxref("Performance.now()")}}
Returns a {{domxref("DOMHighResTimeStamp")}} representing the amount of milliseconds elapsed since a reference instant.
{{domxref("Performance.setResourceTimingBufferSize()")}}
Sets the browser's resource timing buffer size to the specified number of "resource" {{domxref("PerformanceEntry.entryType","type")}} {{domxref("PerformanceEntry","performance entry")}} objects.
{{domxref("Performance.toJSON()")}} {{NotAvailableInWorkerInline}}
Is a jsonizer returning a json object representing the Performance object.

Specifications

Specification Status Comment
{{SpecName('Highres Time Level 2', '#the-performance-interface', 'toJSON()')}} {{Spec2('Highres Time Level 2')}} Defines toJson() method.
{{SpecName('Highres Time', '#the-performance-interface', 'Performance')}} {{Spec2('Highres Time')}} Defines now() method.
{{SpecName('Navigation Timing', '#sec-window.performance-attribute', 'Performance')}} {{Spec2('Navigation Timing')}} Defines timing and navigation properties.
{{SpecName('Performance Timeline Level 2', '#extensions-to-the-performance-interface', 'Performance extensions')}} {{Spec2('Performance Timeline Level 2')}} Changes getEntries() interface.
{{SpecName('Performance Timeline', '#sec-window.performance-attribute', 'Performance extensions')}} {{Spec2('Performance Timeline')}} Defines getEntries(), getEntriesByType() and getEntriesByName() methods.
{{SpecName('Resource Timing', '#extensions-performance-interface', 'Performance extensions')}} {{Spec2('Resource Timing')}} Defines clearResourceTimings() and setResourceTimingBufferSize() methods and the onresourcetimingbufferfull property.
{{SpecName('User Timing Level 2', '#extensions-performance-interface', 'Performance extensions')}} {{Spec2('User Timing Level 2')}} Clarifies mark(), clearMark(), measure() and clearMeasure() interfaces.
{{SpecName('User Timing', '#extensions-performance-interface', 'Performance extensions')}} {{Spec2('User Timing')}} Defines mark(), clearMark(), measure() and clearMeasure() interfaces.

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari (WebKit)
Basic support (timing attribute) 6.0 [1] {{CompatGeckoDesktop("7.0")}} 9.0 15.0 8
navigation attribute {{CompatChrome("9")}} {{CompatGeckoDesktop("7")}} 9.0 {{CompatOpera("15")}} 8
now() on regular context {{ CompatChrome("20.0") }} {{ property_prefix("webkit") }}
{{ CompatChrome("24.0") }}
{{ CompatGeckoDesktop("15.0") }} 10.0 {{CompatVersionUnknown()}} 8
now() in Web workers. {{ CompatChrome("33.0") }} {{ CompatGeckoDesktop("34.0") }} {{CompatUnknown}} {{ CompatVersionUnknown() }} {{CompatNo}}
toJSON() {{CompatNo}} {{CompatGeckoDesktop("25.0")}} 9.0 {{CompatNo}} {{CompatNo}}
getEntries(), getEntriesByType(), getEntriesByName() {{CompatVersionUnknown} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}}
clearResourceTimings(), setResourceTimingBufferSize() {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}}
onresourcetimingbufferfull {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}} {{CompatVersionUnknown}} {{CompatNo}}
mark(), clearMarks(), measure(), clearMeasure() {{CompatChrome(43.0)}} 41 10 33 {{CompatNo}}
Feature Android Android Webview Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile Chrome for Android
Basic support {{CompatNo}} {{CompatVersionUnknown}} {{CompatGeckoMobile("7.0")}} {{CompatGeckoFxOS("7.0")}} 9.0 15.0 9 {{CompatVersionUnknown}}
navigation attribute {{CompatNo}} {{CompatVersionUnknown}} {{CompatNo}} {{CompatNo}} 9.0 {{CompatVersionUnknown}} 9 {{CompatVersionUnknown}}
now() on regular context   {{CompatChrome(25.0)}} {{ CompatGeckoMobile("15.0") }} {{ CompatGeckoFxOS("15.0") }} 10.0 {{CompatVersionUnknown}} 9 {{ CompatChrome("20.0") }} {{ property_prefix("webkit") }}
{{ CompatChrome("25.0") }}
now() in Web workers. {{CompatNo}} {{CompatVersionUnknown} {{ CompatGeckoMobile("34.0") }} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatVersionUnknown}
toJSON() {{CompatNo}} {{CompatNo}} {{CompatGeckoMobile("25.0")}} {{CompatGeckoFxOS("25.0")}} 10.0 {{CompatNo}} {{CompatUnknown}} {{CompatNo}}
getEntries(), getEntriesByType(), getEntriesByName() {{CompatNo}} {{CompatVersionUnknown} {{CompatGeckoMobile("25.0")}} {{CompatGeckoFxOS("25.0")}} 10.0 33 {{CompatNo}} {{CompatVersionUnknown}
clearResourceTimings(), setResourceTimingBufferSize() {{CompatNo}} {{CompatVersionUnknown} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} 33 {{CompatNo}} {{CompatVersionUnknown}
onresourcetimingbufferfull {{CompatNo}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatNo}} 33 {{CompatNo}} {{CompatVersionUnknown}}
mark(), clearMarks(), measure(), clearMeasure() {{CompatNo}} {{CompatChrome(46.0)}} 42 42 10 33 {{CompatNo}} {{CompatChrome(46.0)}}

[1] Member prefixed with webkit have been removed or deprecated.

Revision Source

<div>{{APIRef("High Resolution Time")}}</div>

<p>The <strong><code>Performance</code></strong> interface represents timing-related performance information for the given page.</p>

<p>An object of this type can be obtained by calling the {{domxref("Window.performance")}} read-only attribute.</p>

<div class="note">
<p><strong><em>Note</em>: </strong>This interface and its members are available in <a href="/en-US/docs/Web/API/Web_Workers_API">Web Workers</a>, except where indicated below. Note that some available parts of the interface are not yet documented (see the <a href="https://www.w3.org/TR/performance-timeline/#sec-window.performance-attribute">Performance Timeline</a> and <a href="https://www.w3.org/TR/user-timing/#extensions-performance-interface">User Timing</a> specs for more details.) Also note that performance markers and measures are per context. If you create a mark on the main thread (or other worker), you cannot see it in a worker thread, and vice versa.</p>
</div>

<h2 id="Properties">Properties</h2>

<p><em>The <code>Performance</code> interface doesn't inherit any properties.</em></p>

<dl>
 <dt>{{domxref("Performance.navigation")}} {{readonlyInline}} {{NotAvailableInWorkerInline}}</dt>
 <dd>Is a {{domxref("PerformanceNavigation")}} object representing the type of navigation that occurs in the given browsing context, like the amount of redirections needed to fetch the resource.</dd>
 <dt>{{domxref("Performance.onresourcetimingbufferfull")}}</dt>
 <dd>Is an {{domxref("EventTarget")}} which is a callback that will be called when the {{event("resourcetimingbufferfull")}} event is fired.</dd>
 <dt>{{domxref("Performance.timing")}} {{readonlyInline}} {{NotAvailableInWorkerInline}}</dt>
 <dd>Is a {{domxref("PerformanceTiming")}} object containing latency-related performance information.</dd>
</dl>

<h2 id="Methods">Methods</h2>

<p><em><em>The <code>Performance</code> interface doesn't inherit any </em>method</em>.</p>

<dl>
 <dt>{{domxref("Performance.clearMarks()")}}</dt>
 <dd>Removes the given <em>mark</em> from the browser's performance entry buffer.</dd>
 <dt>{{domxref("Performance.clearMeasures()")}}</dt>
 <dd>Removes the given <em>measure</em> from the browser's performance entry buffer.</dd>
 <dt>{{domxref("Performance.clearResourceTimings()")}}</dt>
 <dd>Removes all {{domxref("PerformanceEntry","performance entries")}} with a {{domxref("PerformanceEntry.entryType","entryType")}} of "<code>resource</code>" from the browser's performance data buffer.</dd>
 <dt>{{domxref("Performance.getEntries()")}}</dt>
 <dd>Returns a list of {{domxref("PerformanceEntry")}} objects based on the given <em>filter</em>.</dd>
 <dt>{{domxref("Performance.getEntriesByName()")}}</dt>
 <dd>Returns a list of {{domxref("PerformanceEntry")}} objects based on the given <em>name</em> and <em>entry type</em>.</dd>
 <dt>{{domxref("Performance.getEntriesByType()")}}</dt>
 <dd>Returns a list of {{domxref("PerformanceEntry")}} objects of the given <em>entry type</em>.</dd>
 <dt>{{domxref("Performance.mark()")}}</dt>
 <dd>Creates a {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's <em>performance entry buffer</em> with the given name.</dd>
 <dt>{{domxref("Performance.measure()")}}</dt>
 <dd>Creates a named {{domxref("DOMHighResTimeStamp","timestamp")}} in the browser's performance entry buffer between two specified marks (known as the <em>start mark</em> and <em>end mark</em>, respectively).</dd>
 <dt>{{domxref("Performance.now()")}}</dt>
 <dd>Returns a {{domxref("DOMHighResTimeStamp")}} representing the amount of milliseconds elapsed since a reference instant.</dd>
 <dt>{{domxref("Performance.setResourceTimingBufferSize()")}}</dt>
 <dd>Sets the browser's resource timing buffer size to the specified number of "<code>resource</code>" {{domxref("PerformanceEntry.entryType","type")}} {{domxref("PerformanceEntry","performance entry")}} objects.</dd>
 <dt>{{domxref("Performance.toJSON()")}} {{NotAvailableInWorkerInline}}</dt>
 <dd>Is a jsonizer returning a json object representing the <code>Performance</code> object.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('Highres Time Level 2', '#the-performance-interface', 'toJSON()')}}</td>
   <td>{{Spec2('Highres Time Level 2')}}</td>
   <td>Defines <code>toJson()</code> method.</td>
  </tr>
  <tr>
   <td>{{SpecName('Highres Time', '#the-performance-interface', 'Performance')}}</td>
   <td>{{Spec2('Highres Time')}}</td>
   <td>Defines <code>now()</code> method.</td>
  </tr>
  <tr>
   <td>{{SpecName('Navigation Timing', '#sec-window.performance-attribute', 'Performance')}}</td>
   <td>{{Spec2('Navigation Timing')}}</td>
   <td>Defines <code>timing</code> and <code>navigation</code> properties.</td>
  </tr>
  <tr>
   <td>{{SpecName('Performance Timeline Level 2', '#extensions-to-the-performance-interface', 'Performance extensions')}}</td>
   <td>{{Spec2('Performance Timeline Level 2')}}</td>
   <td>Changes <code>getEntries()</code> interface.</td>
  </tr>
  <tr>
   <td>{{SpecName('Performance Timeline', '#sec-window.performance-attribute', 'Performance extensions')}}</td>
   <td>{{Spec2('Performance Timeline')}}</td>
   <td>Defines <code>getEntries()</code>, <code>getEntriesByType()</code> and <code>getEntriesByName()</code> methods.</td>
  </tr>
  <tr>
   <td>{{SpecName('Resource Timing', '#extensions-performance-interface', 'Performance extensions')}}</td>
   <td>{{Spec2('Resource Timing')}}</td>
   <td>Defines <code>clearResourceTimings()</code> and <code>setResourceTimingBufferSize()</code> methods and the <code>onresourcetimingbufferfull</code> property.</td>
  </tr>
  <tr>
   <td>{{SpecName('User Timing Level 2', '#extensions-performance-interface', 'Performance extensions')}}</td>
   <td>{{Spec2('User Timing Level 2')}}</td>
   <td>Clarifies <code>mark()</code>, <code>clearMark()</code>, <code>measure()</code> and <code>clearMeasure()</code> interfaces.</td>
  </tr>
  <tr>
   <td>{{SpecName('User Timing', '#extensions-performance-interface', 'Performance extensions')}}</td>
   <td>{{Spec2('User Timing')}}</td>
   <td>Defines <code>mark()</code>, <code>clearMark()</code>, <code>measure()</code> and <code>clearMeasure()</code> interfaces.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<div>{{CompatibilityTable}}</div>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari (WebKit)</th>
  </tr>
  <tr>
   <td>Basic support (<code>timing </code>attribute)</td>
   <td>6.0 [1]</td>
   <td>{{CompatGeckoDesktop("7.0")}}</td>
   <td>9.0</td>
   <td>15.0</td>
   <td>8</td>
  </tr>
  <tr>
   <td><code>navigation</code> attribute</td>
   <td>{{CompatChrome("9")}}</td>
   <td>{{CompatGeckoDesktop("7")}}</td>
   <td>9.0</td>
   <td>{{CompatOpera("15")}}</td>
   <td>8</td>
  </tr>
  <tr>
   <td><code>now()</code> on regular context</td>
   <td>{{ CompatChrome("20.0") }} {{ property_prefix("webkit") }}<br />
    {{ CompatChrome("24.0") }}</td>
   <td>{{ CompatGeckoDesktop("15.0") }}</td>
   <td>10.0</td>
   <td>{{CompatVersionUnknown()}}</td>
   <td>8</td>
  </tr>
  <tr>
   <td><code>now()</code> in Web workers.</td>
   <td>{{ CompatChrome("33.0") }}</td>
   <td>{{ CompatGeckoDesktop("34.0") }}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>toJSON()</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoDesktop("25.0")}}</td>
   <td>9.0</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>getEntries()</code>, <code>getEntriesByType()</code>, <code>getEntriesByName()</code></td>
   <td>{{CompatVersionUnknown}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>clearResourceTimings()</code>, <code>setResourceTimingBufferSize()</code></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>onresourcetimingbufferfull</code></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>mark()</code>, <code>clearMarks()</code>, <code>measure()</code>, <code>clearMeasure()</code></td>
   <td>{{CompatChrome(43.0)}}</td>
   <td>41</td>
   <td>10</td>
   <td>33</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Android Webview</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>Firefox OS</th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
   <th>Chrome for Android</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("7.0")}}</td>
   <td>{{CompatGeckoFxOS("7.0")}}</td>
   <td>9.0</td>
   <td>15.0</td>
   <td>9</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>navigation</code> attribute</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>9.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>9</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>now()</code> on regular context</td>
   <td>&nbsp;</td>
   <td>{{CompatChrome(25.0)}}</td>
   <td>{{ CompatGeckoMobile("15.0") }}</td>
   <td>{{ CompatGeckoFxOS("15.0") }}</td>
   <td>10.0</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>9</td>
   <td>{{ CompatChrome("20.0") }} {{ property_prefix("webkit") }}<br />
    {{ CompatChrome("25.0") }}</td>
  </tr>
  <tr>
   <td><code>now()</code> in Web workers.</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}</td>
   <td>{{ CompatGeckoMobile("34.0") }}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatVersionUnknown}</td>
  </tr>
  <tr>
   <td><code>toJSON()</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoMobile("25.0")}}</td>
   <td>{{CompatGeckoFxOS("25.0")}}</td>
   <td>10.0</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>getEntries()</code>, <code>getEntriesByType()</code>, <code>getEntriesByName()</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}</td>
   <td>{{CompatGeckoMobile("25.0")}}</td>
   <td>{{CompatGeckoFxOS("25.0")}}</td>
   <td>10.0</td>
   <td>33</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}</td>
  </tr>
  <tr>
   <td><code>clearResourceTimings()</code>, <code>setResourceTimingBufferSize()</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>33</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}</td>
  </tr>
  <tr>
   <td><code>onresourcetimingbufferfull</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>33</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
  </tr>
  <tr>
   <td><code>mark()</code>, <code>clearMarks()</code>, <code>measure()</code>, <code>clearMeasure()</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatChrome(46.0)}}</td>
   <td>42</td>
   <td>42</td>
   <td>10</td>
   <td>33</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatChrome(46.0)}}</td>
  </tr>
 </tbody>
</table>
</div>

<p>[1] Member prefixed with webkit have been removed or deprecated.</p>
Revert to this revision