Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #91219
| From | Bonita Montero <Bonita.Montero@gmail.com> |
|---|---|
| Newsgroups | comp.lang.c++ |
| Subject | Re: Unbelievable |
| Date | 2023-08-09 08:17 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <uavb27$3pufk$1@dont-email.me> (permalink) |
| References | <uattpk$3g31h$1@dont-email.me> <uava4i$3ps0s$1@dont-email.me> |
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 );
}
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Cool ! Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-08 19:25 +0200
Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-09 08:01 +0200
Re: Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-09 08:17 +0200
Re: Unbelievable scott@slp53.sl.home (Scott Lurndal) - 2023-08-09 13:57 +0000
Re: Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-09 16:18 +0200
Re: Unbelievable scott@slp53.sl.home (Scott Lurndal) - 2023-08-09 16:01 +0000
Re: Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-10 12:11 +0200
Re: Unbelievable scott@slp53.sl.home (Scott Lurndal) - 2023-08-10 14:44 +0000
Re: Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-10 17:40 +0200
Re: Unbelievable scott@slp53.sl.home (Scott Lurndal) - 2023-08-10 15:49 +0000
Re: Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-10 19:03 +0200
Re: Unbelievable David Brown <david.brown@hesbynett.no> - 2023-08-11 08:28 +0200
Re: Unbelievable Bonita Montero <Bonita.Montero@gmail.com> - 2023-08-11 09:17 +0200
Re: Unbelievable Ben Bacarisse <ben.usenet@bsb.me.uk> - 2023-08-11 12:02 +0100
Re: Unbelievable Paavo Helde <eesnimi@osa.pri.ee> - 2023-08-11 15:31 +0300
csiph-web