If I wanted to accurately measure the time elapsed between an image appearing on screen (e.g. via GUI.DrawTexture(…)) and the user pressing a key, what would be my best approach?
Has anyone else done anything like this?
And the main context I’m interested in here is web browsers. I’m thinking that whatever works best in web browsers (in the Unity plugin) will presumably work at least as well on the desktop. (I also assume there are options available on the desktop that are out of our control in the plugin.)
(For comparison purposes, ActiveX-based online response-time-measuring software boasts “millisecond accuracy”.)
The best you could do is GetTickCount (it’s located in some Mono system libraries; I forget which ones, but a Google search should turn them up) and the functions related to it.
Ticks does not sound promising.
And is this going to be any better than Time.time or Time.realtimeSinceStartup?
I guess what I’d really like to know is whether Unity careful about tracking time since the frame was first rendered or not, e.g. the documentation of Time.time reads:
“The time this frame has started” – OK since before it went on screen or since it went on screen or what? And in what units?
Does this mean that calling it after yield WaitForEndOfFrame() is meaningless? If so, what would be meaningful?
Addendum
According to go-mono.com System.DateTime.Now() should give me a time accurate to the nearest 10,000,000th of a second modulo the accuracy of the system time. The remaining question is when’s the best time to start timing? In a thread after yield WaitForEndOfFrame()?
What exactly are you trying to achieve?
Potentially there is a much better way.
Generally though: perfect timing does not exist and you can’t achieve it, no matter what you do. Your highest precision unless you work with additional threads and never call into unity, is the precision of Update
You think update is best?
I’m writing online survey software for psychologists.
As an aside — I just bought one of those silly Casio cameras that can shoot 1000fps (I found an old model for ~$100 new on Amazon including shipping). Assuming that the camera proves reasonably accurate, I’ll be testing Unity’s timers and I’ll post some results.
The key question is whether I can reliably start (and end) a timer just before or after a screen refresh (inside a web browser…). If so I’m golden.
This is pretty significant, since the only tool out there that can do this stuff right now is Windows-only (and in fact only works reliably in Internet Explorer).