Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifndef CGLIB_TIMER_H
- #define CGLIB_TIMER_H
- #include <chrono>
- class Timer {
- std::chrono::high_resolution_clock::time_point startTime;
- public:
- void start() {
- startTime = std::chrono::high_resolution_clock::now();
- }
- bool isElapsed(double maxTimeSeconds) const {
- std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - startTime);
- return (time_span.count() >= maxTimeSeconds);
- }
- double timeElapsed() const {
- std::chrono::duration<double> time_span = std::chrono::duration_cast<std::chrono::duration<double>>(std::chrono::high_resolution_clock::now() - startTime);
- return time_span.count();
- }
- };
- #endif //CGLIB_TIMER_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement