Allowing Date.now() return fractional as well as integral bits (for submillisecond timing)

# Paul Biggar (15 years ago)

In SpiderMonkey, we can very easily make Date.now() return fractional bits, which allows sub-millisecond timing. I've been using this for a few weeks, and it's been very useful for my small purposes (more accurate benchmarks). We're now looking at making this a feature of Date.now().

According to Brendan's reading of the standard, this is allowed, partially due to Date.now() being underspecified. The question is whether this is a good idea, or if we should shelve it pending the nanoAge proposal, or propose a Date.nowWithFractionalBitsAndABetterName() instead?

The Mozilla bug is here: bugzilla.mozilla.org/show_bug.cgi?id=585152

Comments appreciated.

Thanks, Paul

# Brendan Eich (15 years ago)

On Aug 6, 2010, at 1:27 PM, Paul Biggar wrote:

According to Brendan's reading of the standard, this is allowed,

(Jason Orendorff first noticed this and pointed it out -- I had misread ES5 to require a TimeClip for Date.now.)

partially due to Date.now() being underspecified. The question is whether this is a good idea, or if we should shelve it pending the nanoAge proposal, ...

The nanoAge proposal is from

doku.php?id=proposals:date_and_time&s=nanoage#current_and_elapsed_times

and I believe Paul Biggar and Chris Jones are going to dust this off and make a Harmony strawman proposal from it.

# Douglas Crockford (15 years ago)

On 11:59 AM, Paul Biggar wrote:

In SpiderMonkey, we can very easily make Date.now() return fractional bits, which allows sub-millisecond timing. I've been using this for a few weeks, and it's been very useful for my small purposes (more accurate benchmarks). We're now looking at making this a feature of Date.now().

According to Brendan's reading of the standard, this is allowed, partially due to Date.now() being underspecified. The question is whether this is a good idea, or if we should shelve it pending the nanoAge proposal, or propose a Date.nowWithFractionalBitsAndABetterName() instead?

The Mozilla bug is here: bugzilla.mozilla.org/show_bug.cgi?id=585152

Comments appreciated.

I think this is a good idea. I like this a lot.