6template <
size_t ChronoCount = 1,
size_t HistorySize = 1000>
21 m_data[index].start_time = std::chrono::steady_clock::now().time_since_epoch();
24 void stop(
const int index = 0)
26 m_data[index].end_time = std::chrono::steady_clock::now().time_since_epoch();
27 std::chrono::nanoseconds delta_time = m_data[index].end_time - m_data[index].start_time;
29 m_data[index].total_time += delta_time - m_data[index].history[0];
30 std::shift_left(m_data[index].history.begin(), m_data[index].history.end(), 1);
31 m_data[index].history[HistorySize - 1] = delta_time;
34 template <
typename T = std::chrono::nanoseconds>
37 return std::chrono::duration_cast<T>(m_data[index].delta_time).count();
40 template <
typename T = std::chrono::nanoseconds>
43 return std::chrono::duration_cast<T>(m_data[index].total_time).count() / HistorySize;
50 std::chrono::nanoseconds start_time;
51 std::chrono::nanoseconds end_time;
52 std::chrono::nanoseconds delta_time;
54 std::chrono::nanoseconds total_time;
56 std::array<std::chrono::nanoseconds, HistorySize> history;
59 std::array<Data, ChronoCount> m_data;
void start(const int index=0)
Definition: Timer.hpp:19
Timer()
Definition: Timer.hpp:12
void stop(const int index=0)
Definition: Timer.hpp:24
double elapsed(const int index=0) const
Definition: Timer.hpp:35
double average(const int index=0) const
Definition: Timer.hpp:41