问题描述
在posix上,可以使用timespec来计算准确的时间长度(例如秒和毫秒).不幸的是,我需要使用Visual Studio编译器迁移到Windows. VS time.h库未声明timespec,因此我正在寻找其他选项.尽管我无法检查使用时钟计数对毫秒进行计数的精确程度,但可以搜索使用clock和time_t.
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.
您如何使用/计算操作中经过的时间(如果可能,请使用标准c ++库)?
What do you do/use for calculating time elapse in a operation (if possible using standards c++ library) ?
推荐答案
函数 GetTickCount 通常用于此目的.
还有一个类似的线程: C ++计时,自最后一秒以来的毫秒数
Also a similiar thread: C++ timing, milliseconds since last whole second
这篇关于Windows编译器上的timespec的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!