I got it: they don't use the TSC anymore because there might be
still machines with invariant TSC and because the TSC would not
be contignous across virtual machine migrations. That's while
there's GetSystemTimePreciseAsFileTime, which is still up to
the TSC.
But the're for sure no x64-machines with invariant TSC. And to
manage virtual machine migrations Intel could have added an off-
set added to the TSC before it is read which is set by the kernel.
#include <Windows.h>
#include <iostream>
#include <chrono>
using namespace std;
using namespace chrono;
int main()
{
auto tDo = []( char const *what, void (*fn)( FILETIME * ) )
{
constexpr int64_t ROUNDS = 100'000'000;
auto tGet = [&]()
{
int64_t t;
fn( &(FILETIME &)t );
return t;
};
int64_t tSum = 0, n = 0, tBefore = tGet();
for( int64_t r = ROUNDS, t, tDiff; r--; )
t = tGet(),
tDiff = t - tBefore,
tSum += tDiff,
n += (bool)tDiff,
tBefore = t;
cout << (double)tSum / n << endl;
};
tDo( "precise: ", GetSystemTimePreciseAsFileTime );
tDo( "relaxed: ", GetSystemTimeAsFileTime );
}