Created
March 18, 2015 23:31
-
-
Save hosaka/59412d2ab2102c6a0617 to your computer and use it in GitHub Desktop.
Using chrono datetime utilities from C++11
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
#include <chrono> | |
#include <iostream> | |
#include <thread> | |
int main() | |
{ | |
// time now | |
auto start = std::chrono::high_resolution_clock::now(); | |
std::this_thread::sleep_for(std::chrono::seconds(5)); | |
// time after | |
auto end = std::chrono::high_resolution_clock::now(); | |
// display the difference | |
auto difference = std::chrono::duration_cast<std::chrono::seconds>(end - start).count(); | |
std::cout << "seconds past: " << difference; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment