GetTime ヘルパー関数を実装しようとしています。カウントで測定された現在の時間を取得し、次にシステムの 1 秒あたりのカウント数を取得するため、その関係を使用して現在の時間を秒で取得できます。
しかしその後、私が実際に得られない改善コードがいくつかあります。最後の 2 つのステートメントがあるのはなぜですか?
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;
}