Boost logo

Boost :

From: Matt Hurd (matt.hurd_at_[hidden])
Date: 2004-07-25 20:43:55


On Sat, 24 Jul 2004 11:24:39 +0100, John Maddock <john_at_[hidden]> wrote:
> Just out of interest, what is the problem that prevents the date-time
> library from implementing a microsecond clock using GetSystemTimeAsFileTime
> on Win32?
>
> Thanks,
>
> John.

The resolution supplied by GetSystemTimeAsFileTime may not be what you
think. I get 10 milliseconds resolution out of my machine from the
following code.

#include <Windows.h>
#include <iostream>

int main () {

    FILETIME ft1,ft2;
    GetSystemTimeAsFileTime( &ft1 );
    
    GetSystemTimeAsFileTime( &ft2 );
    std::size_t diff = ft2.dwLowDateTime - ft1.dwLowDateTime;
    while (diff == 0)
    {
        GetSystemTimeAsFileTime( &ft2 );
        diff = ft2.dwLowDateTime - ft1.dwLowDateTime;

    }
    std::cout << "time taken = " << double(ft2.dwLowDateTime -
ft1.dwLowDateTime) /10000 << "milliseconds\n";

    system("pause");
    return 0;
}

Regards,

Matt Hurd.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk