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
6
namespace
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
13
~ScopedTimer
() {
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
Logger.hpp
SLEAK_INFO
#define SLEAK_INFO(...)
Definition
Logger.hpp:20
Sleak::ScopedTimer::~ScopedTimer
~ScopedTimer()
Definition
ScopedTimer.hpp:13
Sleak::ScopedTimer::ScopedTimer
ScopedTimer(const std::string &name)
Definition
ScopedTimer.hpp:10
Sleak
Root namespace for everything the engine exposes.
Definition
Camera.hpp:10
include
private
Core
ScopedTimer.hpp
Generated on
for SleakEngine by
1.16.1