realtime HighPerformanceCounter information

nobody_ spam at spam.spam
Wed Nov 22 01:04:00 PST 2006


"Chris Nicholson-Sauls" <ibisbasenji at gmail.com> wrote in message 
news:ek0i74$fn3$1 at digitaldaemon.com...
>
>
> nobody_ wrote:
>>>>Is it possible to get timing information before stopping a timer?
>>>>
>>>>Something like this:
>>>>
>>>>HighPerformanceCounter c = new HighPerformanceCounter();
>>>>c.start();
>>>>while(c.microseconds()<1000){
>>>>pauze();
>>>>}
>>>>c.stop();
>>>>
>>>>When I do this now, c.microseconds() returns some 'random number :(
>>>
>>>I'm curious, why do you need to keep the timer running?
>>
>>
>> I hoped to use it for timing my main loop :)
>
> Actually... you don't have to do anything.  The implementation of .close() 
> does nothing but query for the current counter state and store it. 
> Repeated calls to .close(), therefore, will equate to repeated re-queries 
> to the counter, with all calls to .*seconds() in between doing their math 
> on the same original .start() result.
>
> So... you already have what you want.  Just make sure to call .close() 
> once before calling the .*seconds() methods.  (At least on Windows... I 
> admit to not checking the linux impl.)
>
> -- Chris Nicholson-Sauls

Hmm.. thanks!

But I still think that a query (count, micro, milli etc) should be used

c.stop
c.milliseconds

Where:
c.milliseconds

should be enough, I think.
It won't really change anything,except be a little be intuitive :)

But anyway, thanks. 





More information about the Digitalmars-d-learn mailing list