Vivid
Loading...
Searching...
No Matches
Timer.h
1#pragma once
2
3#include <chrono>
4
5#include "common/types/SmartPointers.h"
6
7#define NS_TO_MS 1e-6f
8#define MS_TO_S 1e-3f
9
14typedef std::chrono::time_point<std::chrono::high_resolution_clock> TimePoint;
15
20class Timer
21{
22protected:
23 static const std::chrono::high_resolution_clock s_Clock;
24
25 TimePoint m_StartTime;
26 TimePoint m_EndTime;
27
28public:
29 Timer();
30 Timer(Timer&) = delete;
31 virtual ~Timer() = default;
32
37 static TimePoint Now();
38
39 float getTimeMs() const { return (float)(s_Clock.now() - m_StartTime).count() * NS_TO_MS; }
40 float getTimeNs() const { return (s_Clock.now() - m_StartTime).count(); }
41};
Timer class.
Definition: Timer.h:21
static TimePoint Now()
Gets the current time.
Definition: Timer.cpp:3