我正在尝试实现 GetTime 辅助函数。它获取当前时间,以计数为单位,然后获取系统每秒的计数数,因此您可以获取当前时间(以秒为单位)及其关系。
但在那之后,有一些我没有真正得到的改进代码。为什么最后两个语句在那里?
double GetTime()
{
// Current time value, measured in counts
__int64 timeInCounts;
QueryPerformanceCounter((LARGE_INTEGER *)(&timeInCounts));
// To get the frequency (counts per second) of the performance timer
__int64 countsPerSecond;
QueryPerformanceFrequency((LARGE_INTEGER *)(&countsPerSecond));
double r, r0, r1;
// Get the time in seconds with the following relation
r0 = double ( timeInCounts / countsPerSecond );
// There is some kind of acuracy improvement here
r1 = ( timeInCounts - ((timeInCounts/countsPerSecond)*countsPerSecond))
/ (double)(countsPerSecond);
r = r0 + r1;
return r;
}