Timers are a bit off?
Blitz3D Forums/Blitz3D Programming/Timers are a bit off?
| ||
I was using timers to do some work and found that I was getting varying results that wern't quite consistent. I checked some other things and it kept coming back to the timer. I think timers aren't quite accurate and are consistently a bit faster than they should be. If you set it to 30 you actually get 31 or 32, if you set it to 60 you get 62 or 63. I wrote a program that demonstrates this, try using different values in the CreateTimer command and you will see what I mean. If anything I would have thought you would get LESS FPS rather than more but it seems you always get a bit more. This reduces the usefulness of timers if true as if I set 60 then I want it to really be 60 times a second every second not a bit either way. Test program here: ;Test prog for timers Graphics3D 800,600,32,2 SetBuffer BackBuffer() CAMERA=CreateCamera() LIGHT=CreateLight() PIVOT=CreatePivot() SPHERE=CreateSphere() PositionEntity PIVOT,0,0,10 PositionEntity SPHERE,0,0,5 EntityParent sphere,pivot Start_Time=MilliSecs() My_timer=CreateTimer(60) While Not KeyHit(1) TurnEntity pivot,0,1,0 UpdateWorld RenderWorld WaitTimer(My_timer) frame_counter=frame_counter+1 Flip Wend End_Time=MilliSecs() Tot_Time#=End_Time-Start_Time Tot_Time#=Float(Tot_Time#/1000) fps#=Float(frame_counter/Tot_Time) Print fps# Print tot_time Delay 3000 End Darkheart |