Last active
February 28, 2023 10:37
-
-
Save luoyetx/c756327a67378d39ecd2fb8d35da3f5d to your computer and use it in GitHub Desktop.
macros for time evaluation
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
#include <chrono> | |
/*! \brief Timer */ | |
class Timer { | |
using Clock = std::chrono::high_resolution_clock; | |
public: | |
/*! \brief start or restart timer */ | |
inline void Tic() { | |
start_ = Clock::now(); | |
} | |
/*! \brief stop timer */ | |
inline void Toc() { | |
end_ = Clock::now(); | |
} | |
/*! \brief return time in ms */ | |
inline double Elasped() { | |
auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end_ - start_); | |
return duration.count(); | |
} | |
private: | |
Clock::time_point start_, end_; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment