aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/helpers/Timer.cpp
blob: e00c5918f89282efcc5b44ca99b5c8b78e25cfc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include "Timer.hpp"
#include <chrono>

void CTimer::reset() {
    m_tpLastReset = std::chrono::steady_clock::now();
}

std::chrono::steady_clock::duration CTimer::getDuration() {
    return std::chrono::steady_clock::now() - m_tpLastReset;
}

float CTimer::getMillis() {
    return std::chrono::duration_cast<std::chrono::microseconds>(getDuration()).count() / 1000.f;
}

float CTimer::getSeconds() {
    return std::chrono::duration_cast<std::chrono::milliseconds>(getDuration()).count() / 1000.f;
}

const std::chrono::steady_clock::time_point& CTimer::chrono() const {
    return m_tpLastReset;
}