Skip to content

Instantly share code, notes, and snippets.

@rprichard
Created January 22, 2020 20:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rprichard/bcff3b3fb0451207dc9f31ccbab938df to your computer and use it in GitHub Desktop.
Save rprichard/bcff3b3fb0451207dc9f31ccbab938df to your computer and use it in GitHub Desktop.
// https://issuetracker.google.com/147619573
// https://bugs.llvm.org/show_bug.cgi?id=43703
// The program waits for 7200 seconds, and prints the elapsed time every 10 seconds.
// It should always print an elapsed time of just over 10 seconds, but about every 1845
// seconds, it instead prints -1834.66 or so. (The performance counter frequency was 10MHz
// on Wine and the Windows 10 laptop I tested.)
#include <windows.h>
#include <chrono>
#include <thread>
int main() {
LARGE_INTEGER freq;
QueryPerformanceFrequency(&freq);
printf("freq=%lld\n", (long long)freq.QuadPart);
std::chrono::time_point<std::chrono::steady_clock> t1, t2;
t1 = std::chrono::steady_clock::now();
for (int i = 0; i < 7200 / 10; ++i, t1 = t2) {
LARGE_INTEGER counter;
QueryPerformanceCounter(&counter);
t2 = std::chrono::steady_clock::now();
std::chrono::duration<double> diff = t2 - t1;
printf("%f - %lld (0x%016llx)\n",
diff.count(),
(long long)counter.QuadPart,
(unsigned long long)counter.QuadPart * 1000000000ull);
std::this_thread::sleep_for(std::chrono::seconds(10));
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment