mirror of
https://gitlab.com/niansa/discord_llama.git
synced 2025-03-06 20:48:25 +01:00
25 lines
533 B
C++
25 lines
533 B
C++
#ifndef _PHASMOENGINE_TIMER_HPP
|
|
#define _PHASMOENGINE_TIMER_HPP
|
|
#include <chrono>
|
|
|
|
|
|
|
|
class Timer {
|
|
std::chrono::time_point<std::chrono::high_resolution_clock> value;
|
|
|
|
public:
|
|
Timer() {
|
|
reset();
|
|
}
|
|
|
|
void reset() {
|
|
value = std::chrono::high_resolution_clock::now();
|
|
}
|
|
|
|
template<typename Unit = std::chrono::milliseconds>
|
|
auto get() {
|
|
auto duration = std::chrono::duration_cast<Unit>(std::chrono::high_resolution_clock::now() - value);
|
|
return duration.count();
|
|
}
|
|
};
|
|
#endif
|