Skip to content

Instantly share code, notes, and snippets.

@mortennobel
Last active October 30, 2016 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mortennobel/fb06e6cb3eb9203483f1 to your computer and use it in GitHub Desktop.
Save mortennobel/fb06e6cb3eb9203483f1 to your computer and use it in GitHub Desktop.
C++11 timer
#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