realtime HighPerformanceCounter information
Chris Nicholson-Sauls
ibisbasenji at gmail.com
Tue Nov 21 20:05:05 PST 2006
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
More information about the Digitalmars-d-learn
mailing list