W3C

Performance Timeline

W3C Working Draft 1 September 2011 8 May 2012

This version:
http://www.w3.org/TR/2011/WD-performance-timeline-20110901/ http://www.w3.org/TR/2012/WD-performance-timeline-20120508/
Latest version:
http://www.w3.org/TR/performance-timeline/
Latest Editor's Draft:
http://dvcs.w3.org/hg/webperf/raw-file/tip/specs/PerformanceTimeline/Overview.html
Previous version: versions:
http://www.w3.org/TR/2011/WD-performance-timeline-20110811/ http://www.w3.org/TR/2011/WD-performance-timeline-20110901/
Editors:
Jatinder Mann ( , Microsoft Corp. ) , < >
Zhiheng Wang ( , Google Inc. ) , < >

Abstract

This specification defines an unified interface for web applications to access timing information related to navigation store and elements. retrieve performance metric data. This specification does not cover individual performance metric interfaces.

Status of this document

This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index at http://www.w3.org/TR/.

This is a the second Last Call Working Draft of "Performance Timeline". This new version takes into account the High Resolution Time specification and moves the PerformanceTiming interface to Navigation Timing 2.

Please send comments to public-web-perf@w3.org ( archived ) with [PerformanceTimeline] at the start of the subject line by 22 September 2011 . .

A diff document with the previous draft is available.

This document is produced by the Web Performance Working Group. The Web Performance Working Group is part of the Rich Web Clients Activity in the W3C Interaction Domain .

You can find the latest Editor's Draft of this document in the W3C's Mercurial repository , which is updated on a regular basis.

Publication as a Working Draft does not imply endorsement by the W3C Membership. This is a draft document and may be updated, replaced or obsoleted by other documents at any time. It is inappropriate to cite this document as other than work in progress.

This document was produced by a group operating under the 5 February 2004 W3C Patent Policy . W3C maintains a public list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes contains Essential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy .

Table of Contents

  1. 1 Introduction
  2. 2 Conformance requirements
  3. 3 Terminology
  4. 4 Performance Timeline
    1. 4.1 The Performance Timeline
    2. 4.2 The PerformanceEntry interface
    3. 4.3 The window.performance attribute
    4. 4.4 The PerformanceTiming interface
  5. 5 References
  6. Acknowledgements

1 Introduction

This section is non-normative.

This specification introduces Accurately measuring performance characteristics of web applications is an important aspect of making web applications faster. Navigation Timing , Resource Timing , and User Timing are examples of specifications that define timing information related to the navigation of the document, resources on the page, and developer scripts, respectively.

Together these interfaces, and potentially others created in the future, define performance metrics that describe the performance timeline of a unified web application. The Performance Timeline specification provides an unifying interface to store access and retrieve these various performance metric data. This specification does not cover individual metrics from the performance metric interfaces. timeline of a web application.

The following script shows how a developer can use the Performance Timeline interface to obtain timing data related to the navigation of the document, resources on the page and developer scripts.


<!doctype html>
<html>
  <head>
  </head>
  <body onload="init()">
    <img id="image0" src="http://w3c-test.org/webperf/image0.png" />
    <script>
       function init() 
       {
            performance.mark("startWork");
            doWork(); // Some developer code
            performance.mark("endWork");
            
            measurePerf();
       }

       function measurePerf() 
       {
           var perfEntries = performance.getEntries();
           for (i = 0; i < perfEntries.length; i++)
           {
                 if (window.console) console.log("Name: "        + perfEntries[i].name      + 
                                                 " Entry Type: " + perfEntries[i].entryType +
                                                 " Start Time: " + perfEntries[i].startTime + 
                                                 " Duration: "   + perfEntries[i].duration  + "\n");
           }
       }
    </script>
  </body>
</html>

2 Conformance requirements

All diagrams, examples, and notes in this specification are non-normative, as are all sections explicitly marked non-normative. Everything else in this specification is normative.

The key words "MUST", "MUST NOT", "REQUIRED", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in the normative parts of this document are to be interpreted as described in RFC 2119 . For readability, these words do not appear in all uppercase letters in this specification.

Requirements phrased in the imperative as part of algorithms (such as "strip any leading space characters" or "return false and abort these steps") are to be interpreted with the meaning of the key word ("must", "should", "may", etc) used in introducing the algorithm.

Some conformance requirements are phrased as requirements on attributes, methods or objects. Such requirements are to be interpreted as requirements on user agents.

Conformance requirements phrased as algorithms or specific steps may be implemented in any manner, so long as the end result is equivalent. (In particular, the algorithms defined in this specification are intended to be easy to follow, and not intended to be performant.)

The IDL fragments in this specification must be interpreted as required for conforming IDL fragments, as described in the Web IDL specification. [Web IDL]

3 Terminology

The construction "a Foo object", where Foo is actually an interface, is sometimes used instead of the more accurate "an object implementing the interface Foo ".

The term DOM is used to refer to the API set made available to scripts in Web applications, and does not necessarily imply the existence of an actual Document object or of any other Node objects as defined in the DOM Core specifications .

A DOM attribute is said to be getting when its value is being retrieved (such as by author script), and is said to be setting when a new value is assigned to it.

The term "JavaScript" is used to refer to ECMA-262 , rather than the official term ECMAScript, since the term JavaScript is more widely known.

Throughout this work, time is measured in milliseconds since midnight of January 1, 1970 (UTC).

4 Performance Timeline

4.1 The Performance Timeline

All interfaces that participate in the Performance Timeline , such as the PerformanceResourceTiming , PerformanceMark , and PerformanceMeasure interfaces, must adhere to the following rules:

4.2 The PerformanceEntry interface

{ readonly attribute DOMString name; readonly attribute unsigned long long startTime; readonly attribute unsigned short entryType; readonly attribute unsigned long long duration;
interface PerformanceEntry {
  readonly attribute DOMString name;
  readonly attribute DOMString entryType;
  readonly attribute DOMHighResTimeStamp startTime;
  readonly attribute DOMHighResTimeStamp duration;

};

name attribute

The name attribute must return the identifier for this PerformanceEntry object. This identifier does not have to be unique.

startTime entryType attribute

The startTime entryType attribute must return a DOMString that describes the first recorded timestamp type of the interface represented by this performance metric. PerformanceEntry object.

entryType startTime attribute

The entryType startTime attribute must return a const unsigned short exposed on window.performance DOMHighResTimeStamp that defines contains the type time value of the interface represented by first recorded timestamp of this PerformanceEntry object. performance metric.

duration attribute

The duration attribute must return a DOMHighResTimeStamp that contains the time value of the duration of the entire event being recorded by this PerformanceEntry . Typically, this would be the time difference between the last recorded timestamp and the first recorded timestamp of this PerformanceEntry . A performance metric may choose to return a duration of 0, if the duration concept doesn't apply.

4.3 The window.performance attribute

{ (); (in unsigned short entryType); (in DOMString name, in optional unsigned short entryType);
partial interface Performance {
  PerformanceEntryList getEntries();
  PerformanceEntryList getEntriesByType(DOMString entryType);
  PerformanceEntryList getEntriesByName(DOMString name, optional DOMString entryType);
};

  typedef sequence <PerformanceEntry> ;

  typedef sequence <PerformanceEntry> PerformanceEntryList;


The window.performance attribute provides a hosting area for performance measurement related attributes and methods.

getEntries method

The getEntries method retrieves returns a PerformanceEntryList object that contains a copy of all PerformanceEntry objects in chronological order with respect to startTime .

No parameters

Return value

A PerformanceEntryList object.

No exceptions

getEntriesByType method

The getEntriesByType method retrieves returns a PerformanceEntryList object that contains a copy of all PerformanceEntry objects, in chronological order with respect to startTime , that have the same value for the entryType attribute of PerformanceEntry as the entryType parameter.

Parameter

in unsigned short DOMString entryType

The A PerformanceEntryList must contain object that contains a copy of PerformanceEntry objects that have the same value for the entryType attribute of PerformanceEntry as the entryType parameter. If no such PerformanceEntry objects exist, the PerformanceEntryList must be empty.

Return value

A PerformanceEntryList object.

No exceptions

getEntriesByName method

The getEntriesByName method retrieves returns a PerformanceEntryList object that contains a copy of PerformanceEntry objects, in chronological order with respect to startTime , that have the same value for the name attribute of PerformanceEntry as the name parameter and, if specified, have the same value for the entryType attribute of PerformanceEntry as the entryType parameter.

Parameter

in DOMString name

The PerformanceEntryList must contain object that contains a copy of PerformanceEntry objects that have the same value for the name attribute of PerformanceEntry as the name parameter. If no such PerformanceEntry objects exist, the PerformanceEntryList must be empty.

in optional unsigned short DOMString entryType

The PerformanceEntryList must object that only contain contains a copy of PerformanceEntry objects that have the same value for the entryType attribute of PerformanceEntry as the entryType parameter and have the same value for the name attribute of PerformanceEntry as the name parameter. If no such PerformanceEntry objects exist, the PerformanceEntryList must be empty.

Return value

A PerformanceEntryList object.

No exceptions

4.4 The PerformanceTiming interface The PerformanceTiming interface does not extend the PerformanceEntry interface. However, when the getEntriesByType and getEntriesByName methods are called with the entryType argument of PERF_NAVIGATION , a PerformanceEntryList with a PerformanceEntry object with the following values must be returned: The name attribute will return the "document" DOMString. The entryType attribute will return PERF_NAVIGATION . The startTime attribute will return a timestamp with the same value as navigationStart . The duration attribute will return a timestamp equal to the difference between loadEventEnd and navigationStart , respectively.

5 References

[IETF RFC 2119]
Key words for use in RFCs to Indicate Requirement Levels , Scott Bradner, Author. Internet Engineering Task Force, March 1997. Available at http://www.ietf.org/rfc/rfc2119.txt.
[IETF RFC 2616]
Hypertext Transfer Protocol -- HTTP/1.1 , R. Fielding et al., Authors. Internet Engineering Task Force, June 1999. Available at http://www.ietf.org/rfc/rfc2616.txt .
[ DOM Level 3 Core ]
Document Object Model Level 3 Core Specification , A. Le Hors, et al., Editors. World Wide Web Consortium, 7 April 2004. This version of the Document Object Model Level 3 Core Recommendation is http://www.w3.org/TR/2004/REC-DOM-Level-3-Core-20040407. The latest version of DOM Core is available at http://www.w3.org/TR/domcore/.
[ ECMA-262 ]
ECMAScript Language Specification , 5 th 5.1 Edition. ECMA International, Standard ECMA-262, December 2009. June 2011. This version of the ECMAScript Language is available from http://www.ecma-international.org/publications/standards/Ecma-262.htm.
[ HTML5 ]
HTML5 , Ian Hickson, Editor. World Wide Web Consortium, May 2011. This version of the HTML5 is available from http://www.w3.org/TR/html5/ . The latest editor's draft is available at http://dev.w3.org/html5/spec/. [ JSMEASURE ] Wi <a href='http://citeseer