2022-06-24 23:27:02 +02:00
|
|
|
#include "Timer.hpp"
|
2024-10-12 02:29:51 +02:00
|
|
|
#include <chrono>
|
2022-06-24 23:27:02 +02:00
|
|
|
|
|
|
|
void CTimer::reset() {
|
2024-06-25 16:05:39 +02:00
|
|
|
m_tpLastReset = std::chrono::steady_clock::now();
|
2022-06-24 23:27:02 +02:00
|
|
|
}
|
|
|
|
|
2024-06-25 16:05:39 +02:00
|
|
|
std::chrono::steady_clock::duration CTimer::getDuration() {
|
|
|
|
return std::chrono::steady_clock::now() - m_tpLastReset;
|
2022-06-24 23:27:02 +02:00
|
|
|
}
|
|
|
|
|
2024-10-12 02:29:51 +02:00
|
|
|
float CTimer::getMillis() {
|
|
|
|
return std::chrono::duration_cast<std::chrono::microseconds>(getDuration()).count() / 1000.f;
|
2022-06-24 23:27:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
float CTimer::getSeconds() {
|
|
|
|
return std::chrono::duration_cast<std::chrono::milliseconds>(getDuration()).count() / 1000.f;
|
2023-08-05 23:29:33 +02:00
|
|
|
}
|
|
|
|
|
2024-06-25 16:05:39 +02:00
|
|
|
const std::chrono::steady_clock::time_point& CTimer::chrono() const {
|
2023-08-05 23:29:33 +02:00
|
|
|
return m_tpLastReset;
|
2022-06-24 23:27:02 +02:00
|
|
|
}
|