Last active
October 30, 2016 19:52
-
-
Save mortennobel/fb06e6cb3eb9203483f1 to your computer and use it in GitHub Desktop.
C++11 timer
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 <iostream> | |
#include <chrono> | |
using namespace std; | |
// Based on http://stackoverflow.com/a/5524138/420250 | |
int main() | |
{ | |
typedef std::chrono::high_resolution_clock Clock; | |
using FpMilliseconds = std::chrono::duration<float, std::chrono::milliseconds::period>; | |
auto t1 = Clock::now(); | |
cout << "... working ... "<< endl; | |
auto t2 = Clock::now(); | |
cout << std::chrono::duration_cast<FpMilliseconds>(t2 - t1).count() << "ms"<< endl; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment