SleakEngine 1.0.0
C++23 multi-backend game engine
Loading...
Searching...
No Matches
ScopedTimer.hpp
Go to the documentation of this file.
1#ifndef _SCOPEDTIMER_HPP_
2#define _SCOPEDTIMER_HPP_
3
4#include "Core/Logger.hpp"
5
6namespace Sleak {
7 /// RAII stopwatch: logs elapsed time on destruction under the given name.
8 class ScopedTimer {
9 public:
10 ScopedTimer(const std::string& name)
11 : m_Name(name), m_Start(std::chrono::high_resolution_clock::now()) {}
12
14 auto end = std::chrono::high_resolution_clock::now();
15 auto duration = std::chrono::duration_cast<std::chrono::microseconds>(end - m_Start);
16 SLEAK_INFO("{0} took {1} ms",m_Name,duration.count())
17 }
18
19 private:
20 std::string m_Name;
21 std::chrono::time_point<std::chrono::high_resolution_clock> m_Start;
22 };
23}
24
25#endif
#define SLEAK_INFO(...)
Definition Logger.hpp:20
ScopedTimer(const std::string &name)
Root namespace for everything the engine exposes.
Definition Camera.hpp:10