MCPcopy Create free account
hub / github.com/Open-GD/OpenGD / BenchmarkTimer

Class BenchmarkTimer

Source/external/benchmark.h:20–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18#include <GameToolbox/log.h>
19
20class BenchmarkTimer
21{
22public:
23 BenchmarkTimer(const char* name)
24 : m_Name(name), m_Stopped(false)
25 {
26 m_StartTimepoint = std::chrono::high_resolution_clock::now();
27 }
28
29 ~BenchmarkTimer()
30 {
31 if (!m_Stopped)
32 Stop();
33 }
34
35 void Stop()
36 {
37 auto endTimepoint = std::chrono::high_resolution_clock::now();
38
39 long long start = std::chrono::time_point_cast<std::chrono::microseconds>(m_StartTimepoint).time_since_epoch().count();
40 long long end = std::chrono::time_point_cast<std::chrono::microseconds>(endTimepoint).time_since_epoch().count();
41
42 auto duration = start - end;
43 double ms = (duration * 0.001) * -1;
44
45 GameToolbox::log("TIMER [{}]|[{}]", m_Name, ms);
46
47 m_Stopped = true;
48 }
49private:
50 const char* m_Name;
51 std::chrono::time_point<std::chrono::high_resolution_clock> m_StartTimepoint;
52 bool m_Stopped;
53};

Callers 2

initMethod · 0.85
loadLevelMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected