Hmm! does GetTickCount_() show the same? As I sad I'm not entirely sure if that is how that function is coded,
but it does use the value from that shared memory in any case.
My advise. Use ElapsedMilliseconds() which is pretty much the same as GetTickCount if you need just simple timing like wait x seconds etc. Ad it's crossplatform.
If you want a bit more precision on Windows timeGetTime_() is advised, and only use the timeBeginPeriod if you really need it.
Now that PB 4.40 has the new window timers I advice using that instead and use WaitWindowEvent() without a timeout at all.
Again this is cross platform.
I may actually toss out the macro I mentioned above, I think I'm gonna try using Timer Queues instead and redo the graphics loop to work with that.
It's a shame PureBasic has no Timer Queues yet. (the window timers are not accurate nor fast enough for such timings).
GetInterruptTime(), Win NT, x86 & x64
Re: GetInterruptTime(), Win NT, x86 & x64
Me, too.Demivec wrote:In your example code DIY_timeGetTime() returns good results but DIY_GetTickCount() always returns 0. I'm using Windows XP.
I modified the code.
Code: Select all
Procedure.l DIY_GetTickCount() ;for 32bit Windows(NT+)
Protected result.q, *GetTickCount.Long=$7FFE0000
;method 1
;Protected MinimumResolution.l,MaximumResolution.l,CurrentResolution.l
;NtQueryTimerResolution_(@MinimumResolution,@MaximumResolution,@CurrentResolution)
;result = (*GetTickCount\l * MinimumResolution) / 10000
;method 2 - http://uninformed.org/index.cgi?v=2&a=2&p=18
Protected *TickCountMultiplier.Long = $7FFE0004
result = (*GetTickCount\l * *TickCountMultiplier\l) >> 24
ProcedureReturn result
EndProcedure
Re: GetInterruptTime(), Win NT, x86 & x64
@Rescator: No it doesn't show the same time. That's one of the reasons I brought it to your attention. I am looking to understand better methods for consistent timing. This thread topic have certainly been enlightening.Rescator wrote:Hmm! does GetTickCount_() show the same? As I sad I'm not entirely sure if that is how that function is coded,
but it does use the value from that shared memory in any case.
@breeze4me: Your modification works wonderfully. Thanks.
Re: GetInterruptTime(), Win NT, x86 & x64
@breeze4me: Ah yeah, that looks like exactly how TickCount really does it, nice job 

2000, XP, 2003, Vista, 2008, Win7 all use a ~15ms timeslice which is x quantums (Workstation and Server use different quantum settings).
Does anyone know what the timeslice is on Linux and Mac?
By the looks of it, the macro I showed further above (with the quad of 100 nanosec step values read directly from memory) seems to be your best bet.
However it's only NT+, so the safest is probably timeGetTime_() and sadly "cheat" by using timeBeginPeriod_(something).
I did notice that on my system timeBeginPeriod_(5) ;5 ms seems to be more consistent, in other words less "fluttering" than other values.
interestingly enough, on Vista the Media Player also seems to set timeBeginPeriod_(5) on XP it used timeBeginPeriod_(1) I believe.
Use GetTimerResolution() from the fourth post to check the timer resolution before starting Media Player, while it's up, and after.
(Note! make sure you do not have other players up, or a browser with flash etc running as those tend to set timeBeginPeriod_(1) for some reason)

No kidding! I know more about Windows "time" than I wish I ever did, simply told... It sucks!Demivec wrote:I am looking to understand better methods for consistent timing. This thread topic have certainly been enlightening.

2000, XP, 2003, Vista, 2008, Win7 all use a ~15ms timeslice which is x quantums (Workstation and Server use different quantum settings).
Does anyone know what the timeslice is on Linux and Mac?
By the looks of it, the macro I showed further above (with the quad of 100 nanosec step values read directly from memory) seems to be your best bet.
However it's only NT+, so the safest is probably timeGetTime_() and sadly "cheat" by using timeBeginPeriod_(something).
I did notice that on my system timeBeginPeriod_(5) ;5 ms seems to be more consistent, in other words less "fluttering" than other values.
interestingly enough, on Vista the Media Player also seems to set timeBeginPeriod_(5) on XP it used timeBeginPeriod_(1) I believe.
Use GetTimerResolution() from the fourth post to check the timer resolution before starting Media Player, while it's up, and after.
(Note! make sure you do not have other players up, or a browser with flash etc running as those tend to set timeBeginPeriod_(1) for some reason)