Last active
September 10, 2020 13:20
-
-
Save KayEss/fdb3dc2fe997cb0b449c190e198f5982 to your computer and use it in GitHub Desktop.
Quick clock
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
// clang++ -O3 time.cpp -o ttt | |
#include <chrono> | |
#include <iostream> | |
int main() { | |
auto last = std::chrono::duration_cast<std::chrono::nanoseconds>( | |
std::chrono::system_clock::now().time_since_epoch()).count(); | |
while(true) { | |
auto const now = std::chrono::system_clock::now(); | |
auto const ns = std::chrono::duration_cast<std::chrono::nanoseconds>( | |
now.time_since_epoch()).count(); | |
std::cout << (ns / std::nano::den) << '.' << (ns % std::nano::den) | |
<< " -- " << (ns - last) << " \r" << std::flush; | |
last = ns; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment