Nameless Engine
Loading...
Searching...
No Matches
Profiler.hpp
1
#pragma once
2
3
#if defined(ENABLE_PROFILER)
4
5
#include "Remotery/lib/Remotery.h"
6
7
// Source: https://github.com/Celtoys/Remotery/issues/46
8
#define RMT_BEGIN_CPU_SAMPLE_AUTO_NAME() \
9
RMT_OPTIONAL(RMT_ENABLED, { \
10
static rmtU32 rmt_sample_hash_##__LINE__ = 0; \
11
_rmt_BeginCPUSample(__FUNCTION__, 0, &rmt_sample_hash_##__LINE__); \
12
})
13
#define PROFILE_FUNC \
14
RMT_OPTIONAL(RMT_ENABLED, RMT_BEGIN_CPU_SAMPLE_AUTO_NAME()); \
15
RMT_OPTIONAL(RMT_ENABLED, rmt_EndCPUSampleOnScopeExit rmt_ScopedCPUSample##__LINE__);
16
17
#define PROFILE_SCOPE(name) rmt_ScopedCPUSample(name, 0);
18
19
#define PROFILE_SCOPE_START(name) rmt_BeginCPUSample(name, 0);
20
#define PROFILE_SCOPE_END rmt_EndCPUSample();
21
22
namespace
ne {
24
class
Profiler {
25
public
:
26
Profiler(
const
Profiler&) =
delete
;
27
Profiler& operator=(
const
Profiler&) =
delete
;
28
30
~Profiler() { rmt_DestroyGlobalInstance(pRemotery); }
31
33
static
void
initialize() {
static
Profiler profiler; }
34
35
private
:
37
Profiler() { rmt_CreateGlobalInstance(&pRemotery); }
38
40
Remotery* pRemotery =
nullptr
;
41
};
42
}
// namespace ne
43
44
#else
45
46
#define PROFILE_FUNC
47
#define PROFILE_SCOPE(name)
48
#define PROFILE_SCOPE_START(name)
49
#define PROFILE_SCOPE_END
50
51
#endif
src
engine_lib
public
misc
Profiler.hpp
Generated by
1.9.5