Created
July 7, 2016 02:06
-
-
Save Nathaniel100/812f037ffb28ba7e8529edc08ec68989 to your computer and use it in GitHub Desktop.
c++11 timer class
This file contains hidden or 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
class Timer { | |
public: | |
Timer() : beg_(clock_::now()) {} | |
void reset() { beg_ = clock_::now(); } | |
double elapsed() const { | |
return std::chrono::duration_cast<second_>(clock_::now() - beg_).count(); | |
} | |
private: | |
typedef std::chrono::high_resolution_clock clock_; | |
typedef std::chrono::duration<double, std::ratio<1> > second_; | |
std::chrono::time_point<clock_> beg_; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment