Closed
Bug 860980
Opened 12 years ago
Closed 12 years ago
performance.now is 2x-5x slower than Date.now
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
RESOLVED
DUPLICATE
of bug 824495
People
(Reporter: Harald, Unassigned)
Details
Run http://jsperf.com/new-date-vs-date-now-vs-performance-now/5
Even though good performance is implied by the namespace, Date.now is much faster than performance.now.
If game developer see this test they might prefer Date.now as they fear performance implications.
Not sure if this is a JavaScript Engine bug.
Comment 1•12 years ago
|
||
I updated the testcase to separate out the effects of getting the performance object from calling now() on it. See http://jsperf.com/new-date-vs-date-now-vs-performance-now/6
With that change, the "Cached performance object" test runs at the same speed for me, on Mac, as the "Date.now" test. See also bug 824495 and the data there.
Is there something in this bug that's not covered by bug 824495 and is dependencies?
Comment 2•12 years ago
|
||
And note that performance.now() has to produce higher quality results than Date.now(), which does mean that in many cases it will in fact take longer to run (esp. on Windows), even if you ignore the slowness from the "performance" getter...
Reporter | ||
Comment 3•12 years ago
|
||
Seems (In reply to Boris Zbarsky (:bz) from comment #1)
> Is there something in this bug that's not covered by bug 824495 and is
> dependencies?
Seems like Vlad got the gist, and your "fix" to cache the property works wonders and shows that the problem is just the window property access.
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → DUPLICATE
Comment 4•12 years ago
|
||
FYI, these are the numbers on my system (Windows 7-64, i7-3630qm) with a nightly which I updated just now:
Date.now(); 3,009,581 ±0.30 %69% slower
+new Date(); 1,439,573 ±0.77% 85% slower
performance.now() 2,569,185 ±1.07% 74% slower
new Date().getTime() 2,388,121 ±0.95% 76% slower
new Date().valueOf() 2,390,906 ±0.38% 76% slower
Cached performance object
perf.now() 9,845,328 ±0.15% fastest
You need to log in
before you can comment on or make changes to this bug.
Description
•