[whatwg] Timing API proposal for measuring intervals

The discussion of audio concerns seems to have died down.  I think anything
specific to audio will be additive to this API, and there are still several
non-audio use cases, so here's an updated proposal:

double window.performance.now();

The idea of putting it on window.performance is that this seems closely
related to the UserTiming spec currently under development by the Web Perf
working group (
http://w3c-test.org/webperf/specs/UserTiming/#the-usertiming-interface).
 When window.performance.now() is called, the browser returns a double
representing the number of milliseconds that have elapsed since the most
recent top-level navigation in that context.  That's the same time value
that is used by the navigation and user timing specs.  Defining this as a
function instead of an attribute makes it clearer that the returned value
can change on every access and is not fixed while script is running.  This
is important for the script profiling use case.  When a fixed time value is
needed, as for example in requestAnimationFrame, it should be provided by
that API.  By putting this on window.performance, we can pick a nice short
function name without having to worry so much about potential collisions
with existing content.

- James

Received on Tuesday, 16 August 2011 19:08:10 UTC