realtime HighPerformanceCounter information

nobody_ spam at spam.spam
Wed Nov 22 00:57:31 PST 2006


"Lutger" <lutger.blijdestijn at gmail.com> wrote in message 
news:ek0eqg$cns$1 at digitaldaemon.com...
> nobody_ wrote:
>> I've just been checking the souce code of  std.perf and I can't see why 
>> it isn't:
>>
>> interval_type periodCount()
>> {
>>     if(running){
>>         return m_end - m_start;
>>     }else{
>>         QueryPerformanceCounter(&m_inter);
>>          return m_inter - m_start;
>>     }
>> }
>>
>> If the counter doesn't take any more resources than its starting value, 
>> stop() can be left out totally
>> and the code would be as simple as this :)
>>
>> interval_type periodCount()
>> {
>>         QueryPerformanceCounter(&m_inter);
>>          return m_inter - m_start;
>> }
>
> periodCount does not return the time, but the number of ticks. To get the 
> time in seconds you have to divide by the frequency, which is represented 
> by sm_freq in std.perf. The other stuff is for adjusting to milli- and 
> microseconds and not getting rounding errors.

I know what periodCount is for :)
As it is used by milliseconds etc, you only have to change that function.

> I believe this (HighPerformanceCounter) is windows-only code though.
>
>> If I were into object programming, I might even be able to implement it.
>> But as I'm not into it, it might just be a bad idea ;)
>
> Or not, it might just be simple and fun to do. A timer could very well be 
> a single tiny function that returns the time since application was loaded 
> or whatever, no object orientation needed at all.

I meant I wasn't sure about my capabilities of reading the code :) 





More information about the Digitalmars-d-learn mailing list