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

performance.now, attribute or function?

From: Jonas Sicking <jonas@sicking.cc>
Date: Wed, 7 Mar 2012 12:41:24 -0800
Message-ID: <CA+c2ei_i1+zw1tK9-YiWX5SzPHAUHobtuqq-pBZr0QTgm=z_6g@mail.gmail.com>
To: public-web-perf@w3.org
Hi Perf minded people.

I just noticed that window.performance.now is defined to be an
attribute. So the syntax is:

x = window.performance.now;

This feels a bit strange to me since generally it feels like
attributes represent a more constant value. I.e. that they only change
in response to explicit actions like function calls.

In particular. I would have expected

foo.bar == foo.bar;

to always test true, for basically any 'foo' object and 'bar' property
name. However that obviously isn't the case for performance.now.

It seems a bit more intuitive that

foo.bar() == foo.bar();

might not test true (at least in a non-functional language like JS).

Obviously this isn't inherently the case. A getter can take just the
same types of actions as a function. It just seems like bad
programming style to do so.

How would people feel about changing it to window.performance.now()?

/ Jonas
Received on Wednesday, 7 March 2012 20:42:22 UTC

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