Created
January 22, 2020 20:51
-
-
Save rprichard/bcff3b3fb0451207dc9f31ccbab938df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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