Can anyone give advice as to the
accuracy and precision of timing in JavaScript?
I need to time user responses with a calculated accuracy and precision.
Date().getTime
was the function I was thinking about using to make measurements. I imagine the accuracy is near perfect, but I want to calculate the precision.
I want to emulate a user using setTimeout() so I can calculate precision of getTime().
setTimeOut()
Do these two functions use the same clock? If one varies say +10msec will the other as well effectively making my experiment to calculate precision useless?
Someone already did this:
http://ejohn.org/blog/accuracy-of-javascript-time/
Resolution Information
You should read this article. It talks about the new High resolution Timer and compares it with the current
Dateobject.Basically there are two key points:
With
Dateyou’ll get miliseconds resolution, though the accuracy of it is not guaranteed. According to the High resolution Timer specs:I’d recommend you read both articles to get a clearer idea about this.