Skip to content

Instantly share code, notes, and snippets.

@hosaka
Created March 18, 2015 23:31
Show Gist options
  • Save hosaka/59412d2ab2102c6a0617 to your computer and use it in GitHub Desktop.
Save hosaka/59412d2ab2102c6a0617 to your computer and use it in GitHub Desktop.
Using chrono datetime utilities from C++11
#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