Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

window.performance.now() is undefined in Safari 9

I have a problem with window.performance.now() in Safari 9. My OS is OS X Mavericks in Macbook Pro Mid 2010.

Apple released Safari 9 for OS X Yosemite and Mavericks users: http://www.macrumors.com/2015/09/30/apple-releases-safari-9-for-yosemite-users/

caniuse.com/#search=performance says that in Safari 8 and 9 have support for window.performance.now():

enter image description here

but I just today updated from Safari 7 to Safari 9 and big disappointment: window.performance is undefined!

enter image description here

Should it work? Does it work for someone? Is this problem with my OS and/or hardware?

like image 650
Timo Kähkönen Avatar asked Oct 04 '15 19:10

Timo Kähkönen


People also ask

What does performance now () return?

The performance. now() method returns a DOMHighResTimeStamp , measured in milliseconds. The returned value represents the time elapsed since the time origin.

How do I reset my performance now?

There's no way to reset performance. now() . What you can do is to save current performance. now() when the timer starts and just substract it afterwards.

Can I use performance now?

performance. now() has full support in all modern browsers, starting from Chrome 24, Firefox 15, and IE10.

Is performance now faster than date now?

It's purely dependent on the time since the code started running, and clock changes do not affect the time. It's also more accurate: counting us (microseconds) instead of ms. As for support, Date. now() has slightly more support than performance.


1 Answers

It was due to Mavericks. Safari 9 installed well on Mavericks, but for some reason performance.now() didn't work.

May be Apple will fix this bug in the next Safari update.

I installed El Capitan and it worked:

enter image description here

Here is my updated test page that uses performance.now() to measure function execution time: http://jsbin.com/qocojaducu/1/edit?js,output.

like image 92
Timo Kähkönen Avatar answered Oct 19 '22 18:10

Timo Kähkönen