Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #91218

Unbelievable

From Bonita Montero <Bonita.Montero@gmail.com>
Newsgroups comp.lang.c++
Subject Unbelievable
Date 2023-08-09 08:01 +0200
Organization A noiseless patient Spider
Message-ID <uava4i$3ps0s$1@dont-email.me> (permalink)
References <uattpk$3g31h$1@dont-email.me>

Show all headers | View raw


I disassembled GetSystemTimeAsFileTime() some years ago and it used
x86's RDTSC internally. But now it switched to a memory-mapped hard-
ware register with about millisecond resolution. Before it had 100ns
-resolution.

#include <Windows.h>
#include <iostream>
#include <chrono>

using namespace std;
using namespace chrono;

int main()
{
	constexpr int64_t ROUNDS = 100'000'000;
	auto tGet = []()
	{
		int64_t t;
		GetSystemTimeAsFileTime( &(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;
}

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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