Created
May 6, 2017 13:27
-
-
Save clarkzjw/6a929fc0acbdc1fbf5954cf82966b1ef to your computer and use it in GitHub Desktop.
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> | |
class TicToc | |
{ | |
private: | |
typedef std::chrono::high_resolution_clock clock; | |
typedef std::chrono::microseconds res; | |
clock::time_point t1, t2; | |
public: | |
void tic() | |
{ | |
t1 = clock::now(); | |
} | |
void toc() | |
{ | |
t2 = clock::now(); | |
std::cout << "Elapsed time: " | |
<< std::chrono::duration_cast<res>(t2 - t1).count() / 1e6 | |
<< " seconds." << std::endl; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment