Vulkan/src/Common/Timer.h

42 lines
680 B
C++

#ifndef TIMER_H
#define TIMER_H
// Custom includes
#include <chrono>
class RunTimer {
public:
void startTimer();
int endTimer();
private:
// Aliases
using Clock = std::chrono::steady_clock;
using TimePoint = std::chrono::time_point<Clock>;
TimePoint startTime;
TimePoint endTime;
};
#endif // End of header
#ifdef TIMER_IMPL
#ifndef TIMER_IMPL_H
#define TIMER_IMPL_H
// Implementation
void RunTimer::startTimer(){
startTime = Clock::now();
}
int RunTimer::endTimer() {
endTime = Clock::now();
auto elapsed = std::chrono::duration_cast<std::chrono::seconds>(endTime - startTime);
return elapsed.count();
}
#endif
#endif