|
-
Oct 26th, 2018, 08:22 AM
#4
Re: TimerEx, hi precision timer using QueryPerformanceCounter
 Originally Posted by The trick
FYI, if you use VB_PredeclaredId = True then you have a small overhead because each access to an object translated to:
Code:
If cObj Is Nothing Then Set cObj = New cObj
Hmm, that's interesting. I suppose that's fine with me so long as the overhead is consistent.
-------------
 Originally Posted by wqweto
I'm wondering if the performance optimization of caching cFreq is worth the whole class as the uncomplicated version can be implemented with a single function in a .bas file:
thinBasic Code:
Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As Currency) As Long Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As Currency) As Long Public Function TimerEx() As Double Dim cFreq As Currency Dim cValue As Currency QueryPerformanceFrequency cFreq QueryPerformanceCounter cValue TimerEx = cValue / cFreq End Function
cheers,
</wqw>
And that's also an interesting question. I guess I'll have to use QueryPerformanceCounter and QueryPerformanceFrequency to test themselves. Shouldn't be difficult though.
----------
Taking both of the above together though, I suppose in an ideally optimized situation, we'd keep it all in a BAS module and also have an "InitTimerEx" call that was mandated before "TimerEx" was called. We could check in the "TimerEx" procedure, but, again, that'd be some unwanted overhead.
Maybe I'll take a closer look at this stuff later,
Elroy
Any software I post in these forums written by me is provided "AS IS" without warranty of any kind, expressed or implied, and permission is hereby granted, free of charge and without restriction, to any person obtaining a copy. To all, peace and happiness.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|