W3C home > Mailing lists > Public > public-web-perf@w3.org > August 2012

Re: Disparity between time bases in HighResolutionTime and ResourceTiming

From: James Robinson <jamesr@google.com>
Date: Thu, 30 Aug 2012 20:16:34 -0700
Message-ID: <CAD73mdJ_5x_Reh8SaKWYUHhnqmE4BNF9CJSAO=34WBzgtLq_cw@mail.gmail.com>
To: James Simonsen <simonjam@chromium.org>
Cc: Jatinder Mann <jmann@microsoft.com>, "public-web-perf@w3.org" <public-web-perf@w3.org>
On Thu, Aug 30, 2012 at 8:08 PM, James Simonsen <simonjam@chromium.org>wrote:

> On Thu, Aug 30, 2012 at 5:59 PM, Jatinder Mann <jmann@microsoft.com>wrote:
>>   Also I should add, though we may not want to encourage it, developers
>> can always compare High Resolution Time with Date.now() by just adding
>> performance.navigationStart to the performance.now() call. (In the current
>> definition, they would add their documentís performance.navigationStart and
>> with the proposed definition, they would add the
>> parent.performance.navigationStart). This time will only be accurate to the
>> millisecond, but will truly be comparable.
Date.now() and performance.now() are not anything close to comparable.
 They will advance at different rates on different people's computes.
 Date.now() is not necessarily nondecreasing, let alone monotonic.  If you
have a Date.now() value it tells you something about what that user's
system clock thinks the time is at the time you called Date.now(), but it
doesn't tell you anything else.  If you have a performance.now() value it
tells you how much wall clock time has elapsed since a previous time you
called performance.now() or since a marker uses the performance.now()
clock.  Any code that mixes Date.now() with performance.now() is not just
inaccurate, it's flat out wrong.

This concern is not theoretical - we've observed widespread clock skew
including clocks going backwards by doing experiments in the wild that
compare Date.now() time intervals against server side times.

> Is this spec'd somewhere? I was always under the impression Date.now()
> should change if the user's clock changes. That's how Chrome works anyway.

James is right - Date.now() changes if the system clock changes.

 - James
Received on Friday, 31 August 2012 03:17:02 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 6 January 2015 21:04:33 UTC