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 971623 of Performance

  • Revision slug: Web/API/Performance
  • Revision title: Performance
  • Revision id: 971623
  • Created:
  • Creator: AFBarstow
  • Is current revision? No
  • Comment +User Timing data to BC table

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.timing")}} {{readonlyInline}} {{NotAvailableInWorkerInline}}
Is a {{domxref("PerformanceTiming")}} object containing latency-related performance information.
{{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.

Methods

The Performance interface doesn't inherit any method.

{{domxref("Performance.now()")}}
Returns a {{domxref("DOMHighResTimeStamp")}} representing the amount of milliseconds elapsed since a reference instant.
{{domxref("Performance.toJSON()")}} {{NotAvailableInWorkerInline}}
Is a jsonizer returning a json object representing the Performance object.
{{domxref("Performance.getEntries()")}}
Returns a list of {{domxref("PerformanceEntry")}} objects based on the given filter.
{{domxref("Performance.getEntriesByType()")}}
Returns a list of {{domxref("PerformanceEntry")}} objects of the given entry type.
{{domxref("Performance.getEntriesByName()")}}
Returns a list of {{domxref("PerformanceEntry")}} objects based on the given name and entry type.
{{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.setResourceTimingBufferSize()")}}
Sets the browser's resource timing buffer size to the specified number of "resource" {{domxref("PerformanceEntry.entryType","type")}} {{domxref("PerformanceEntry","performance entry")}} objects.

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 {{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() }} {{CompatUnknown}}
toJSON() {{CompatNo}} {{CompatGeckoDesktop("25.0")}} 9.0 {{CompatNo}} {{CompatNo}}
getEntries(), getEntriesByType(), getEntriesByName() {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}} {{CompatNo}}
clearResourceTimings(), setResourceTimingBufferSize() {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}}
onresourcetimingbufferfull {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
mark(), clearMark(), measure(), clearMeasure() 43 41 10 33 {{CompatNo}}
Feature Android Firefox Mobile (Gecko) Firefox OS IE Phone Opera Mobile Safari Mobile
Basic support {{CompatNo}} {{CompatGeckoMobile("7.0")}} {{CompatGeckoFxOS("7.0")}} 9.0 15.0 9
navigation attribute {{CompatNo}} {{CompatNo}} {{CompatNo}} 9.0 {{CompatNo}} 9
now() on regular context {{ CompatChrome("20.0") }} {{ property_prefix("webkit") }}
{{ CompatChrome("24.0") }}
{{ CompatGeckoMobile("15.0") }} {{ CompatGeckoFxOS("15.0") }} 10.0 {{CompatNo}} 9
now() in Web workers. {{CompatUnknown}} {{ CompatGeckoMobile("34.0") }} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}} {{CompatUnknown}}
toJSON() {{CompatNo}} {{CompatGeckoMobile("25.0")}} {{CompatGeckoFxOS("25.0")}} 10.0 {{CompatNo}} {{CompatUnknown}}
getEntries(), getEntriesByType(), getEntriesByName() {{CompatVersionUnknown}} {{CompatGeckoMobile("25.0")}} {{CompatGeckoFxOS("25.0")}} 10.0 {{CompatNo}} {{CompatNo}}
clearResourceTimings(), setResourceTimingBufferSize() {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatNo}}
onresourcetimingbufferfull {{CompatVersionUnknown}} {{CompatVersionUnknown}} {{CompatUnknown}} {{CompatNo}} {{CompatVersionUnknown}} {{CompatNo}}
mark(), clearMark(), measure(), clearMeasure() 46 42 42 10 33 {{CompatNo}}

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.timing")}} {{readonlyInline}} {{NotAvailableInWorkerInline}}</dt>
 <dd>Is a {{domxref("PerformanceTiming")}} object containing latency-related performance information.</dd>
 <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>
</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.now()")}}</dt>
 <dd>Returns a {{domxref("DOMHighResTimeStamp")}} representing the amount of milliseconds elapsed since a reference instant.</dd>
 <dt>{{domxref("Performance.toJSON()")}} {{NotAvailableInWorkerInline}}</dt>
 <dd>Is a jsonizer returning a json object representing the <code>Performance</code> object.</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.getEntriesByType()")}}</dt>
 <dd>Returns a list of {{domxref("PerformanceEntry")}} objects of the given <em>entry type</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.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.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>
</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</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>{{CompatUnknown}}</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>{{CompatNo}}</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>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>mark()</code>, <code>clearMark()</code>, <code>measure()</code>, <code>clearMeasure()</code></td>
   <td>43</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>Firefox Mobile (Gecko)</th>
   <th><strong>Firefox OS</strong></th>
   <th>IE Phone</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoMobile("7.0")}}</td>
   <td>{{CompatGeckoFxOS("7.0")}}</td>
   <td>9.0</td>
   <td>15.0</td>
   <td>9</td>
  </tr>
  <tr>
   <td><code>navigation</code> attribute</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>9.0</td>
   <td>{{CompatNo}}</td>
   <td>9</td>
  </tr>
  <tr>
   <td><code>now()</code> on regular context</td>
   <td>{{ CompatChrome("20.0") }} {{ property_prefix("webkit") }}<br />
    {{ CompatChrome("24.0") }}</td>
   <td>{{ CompatGeckoMobile("15.0") }}</td>
   <td>{{ CompatGeckoFxOS("15.0") }}</td>
   <td>10.0</td>
   <td>{{CompatNo}}</td>
   <td>9</td>
  </tr>
  <tr>
   <td><code>now()</code> in Web workers.</td>
   <td>{{CompatUnknown}}</td>
   <td>{{ CompatGeckoMobile("34.0") }}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>toJSON()</code></td>
   <td>{{CompatNo}}</td>
   <td>{{CompatGeckoMobile("25.0")}}</td>
   <td>{{CompatGeckoFxOS("25.0")}}</td>
   <td>10.0</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatUnknown}}</td>
  </tr>
  <tr>
   <td><code>getEntries()</code>, <code>getEntriesByType()</code>, <code>getEntriesByName()</code></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("25.0")}}</td>
   <td>{{CompatGeckoFxOS("25.0")}}</td>
   <td>10.0</td>
   <td>{{CompatNo}}</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>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>onresourcetimingbufferfull</code></td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatUnknown}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>mark()</code>, <code>clearMark()</code>, <code>measure()</code>, <code>clearMeasure()</code></td>
   <td>46</td>
   <td>42</td>
   <td>42</td>
   <td>10</td>
   <td>33</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>
Revert to this revision