I have read this implementation in 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;
}
I guess that the result of GetElapsedTime() is in milliseconds, is that right? Why is that?
If
ClockMSis returning milliseconds, thenGetElapsedTimewill return the time in seconds. For example, if the elapsed time (the difference between stop and start) was 1000 ms, then the return value would be1000 ms * .001 second/ms = 1 second.