我已经阅读了C++的实现;

int ClockTimer::ClockMS()
{
   return clock() * 1000 / CLOCKS_PER_SEC;
}

double ClockTimer::CLOCK()
{
    return ClockMS() * 0.001;
}

void ClockTimer::StartTimer()
{
   _time_start = ClockMS();
}

void ClockTimer::StopTimer(int verb)
{
   _time_stop = ClockMS();
}


float ClockTimer::GetElapsedTime()
{
    return (_time_stop - _time_start)  * 0.001f;
}

我猜GetElapsedTime()的结果以毫秒为单位,对吗?这是为什么?

最佳答案

如果ClockMS返回毫秒,那么GetElapsedTime将返回以秒为单位的时间。例如,如果经过的时间(停止与开始之间的差)为1000 ms,则返回值为1000 ms * .001 second/ms = 1 second

09-26 06:05