Boost logo

Boost :

From: Russell Hind (rhind_at_[hidden])
Date: 2004-04-19 10:12:18

Anthony Williams wrote:
> On Windows, you could use GetTickCount to do the timing, with
> GetSystemTimeAsFileTime and SystemTimeToFileTime to get the limits --- e.g.
> const SYSTEMTIME suppliedEndTime=...;
> FILETIME endTime={0};
> SystemTimeToFileTime(&suppliedEndTime,&endTime);
> FILETIME startTime={0};
> GetSystemTimeAsFileTime(&startTime);
> DWORD const initialTick=GetTickCount();
> ULONGLONG const diff=reinterpret_cast<ULARGE_INTEGER const&)(endTime).QuadPart-
> reinterpret_cast<ULARGE_INTEGER const&)(startTime).QuadPart;
> ULONGLONG const elapsedTicks=diff/10000;
> ASSERT(elapsedTicks<=ULONG_MAX);
> while((GetTickCount()-initialTick)<elapsedTicks)
> {
> doStuff();
> }

TickCount can wrap around, though (I think its something like 47.9 days
or something like that).

There is also QueryPerformanceCounter for high resolution tick count,
QueryPerformanceFrequency will give you the frequency of the counter as
it will vary from system to system.


Boost list run by bdawes at, gregod at, cpdaniel at, john at