views:

49

answers:

2

Does anyone know how accurate flash timing is and its ability to identify the client monitor's refresh rate? I need to be able to calculate time durations with up to 10 milliseconds accuracy of response time. Also if it is off, is there a way to possibly calibrate the response based on monitor refresh rate and action to make sure the value is as close to precise as possible? Any info would be great! Even better would be some examples of existing benchmark test.

Update:

I've found this post which is helpful but wanted to see if anyone else has anything else to add on the subject.

http://stackoverflow.com/questions/1014009/as3-how-accurate-are-the-gettimer-method-and-the-timer-class

http://www.kaourantin.net/2006/05/frame-rates-in-flash-player.html

+1  A: 

You don't get monitor refresh rate from Flash, even in AIR. Yes, frames can render in different time (especially under heavy load). AFAIK, your best source of accurate time is getTimer(). Animation based on getTimer() in ENTER_FRAME is smooth (provided frame rate is high enough), although frame rate may vary.

Edit: Your code has chance to execute between frame changes, so set frame rate high and keep load small. This way you get more chances in time to respond. I believe the accuracy of getTimer() is up to 1 ms, but it is a little hard to check. Run program for few hours, then compare getTimer() and actual time passed?..

alxx
+2  A: 

No way to detect it, and the Flash Player doesn't use vsync so calculating update times wouldn't be of much use.

It all depends on what you want to use it for. If you're just timing something on screen, use getTimer as it's accurate to 1ms -- you absolutely don't need to know the monitor refresh rate for that.

Also, the Timer class is unreliable for calls so either roll your own timer class, or use getTimer on onEnterFrames (most accurate way to do screen updates).

zeh
Small correction: Timer isn't perfect for timing, but rolling your own won't be any better (or worse)..
fenomas
Correction to the correction: it will, because if you build it correctly, you can at least avoid the cumulative offset created by the Timer class (http://www.computus.org/journal/?p=25).
zeh