No announcement yet.

Unclock/StopWatch broken?

  • Filter
  • Time
  • Show
Clear All
new posts

    Unclock/StopWatch broken?

    Yea i'm cross posting from the BeyondUnreal forums, but i'm getting desperate. The original thread is here...

    I'm trying to time some code and getting some weird results. I'm using some code like the following....
    exec function DoMyTest()
    	local float elapsed;
    	Clock( elapsed );
    	// do some junk...
    	UnClock( elapsed );
    	ClientMessage( elapsed$ "ms" );
    The problem is that i get what seems to be garbage elapsed times. For instance i'll get 324.34ms, 322.47ms, then get -500.23ms. This happens with StopWatch() too.

    Timing something that with my watch it took 63 seconds... what does UnClock give me? -223.67ms!!!

    People have suggested averaging results and dropping negative time, but after seeing this i've lost all faith in Clock/Unclock being right at all for any timing.

    Any other suggestions on how to get it working?

    I'm pretty sure this is a bug in UT2K4.;en-us;327809

    In particular the part...

    Some programs work with the result of QueryPerformanceFrequency as a signed integer value, which has only 31 bits of precision and a sign flag. These programs behave incorrectly on these faster CPUs.
    That sounds like the behavior i'm getting from Clock/UnClock().

    The only thing that can be done is do my timing on a slower machine until this is fixed in a future patch ( please ).