c++visual-studioelapsedtimetimespec

timespec on windows compilers


On posix it is possible to use timespec to calculate accurate time length (like seconds and milliseconds). Unfortunately I need to migrate to windows with Visual Studio compiler. The VS time.h library doesn't declare timespec so I'm looking for other options. As far as could search is it possible to use clock and time_t although I could't check how precise is counting millisecons with clock counting.

What do you do/use for calculating time elapse in a operation (if possible using standards c++ library) ?


Solution

  • The function GetTickCount is usually used for that.

    Also a similiar thread: C++ timing, milliseconds since last whole second