Grindstone Game Engine
v0.2.0
An open source game engine and toolkit.
Loading...
Searching...
No Matches
Profiling.hpp
1
#ifndef _PROFILING_HPP
2
#define _PROFILING_HPP
3
4
#include <string>
5
#include <chrono>
6
#include <vector>
7
#include <filesystem>
8
9
namespace
Grindstone {
10
namespace
Profiler {
11
struct
Result
{
12
std::string name;
13
float
start, end;
14
uint32_t depth;
15
uint32_t threadId;
16
};
17
18
struct
InstrumentationSession
{
19
std::string name;
20
std::filesystem::path path;
21
std::vector<Result> results;
22
};
23
24
class
Manager {
25
private
:
26
InstrumentationSession
* currentSession =
nullptr
;
27
InstrumentationSession
* otherSession =
nullptr
;
28
InstrumentationSession
sessionA;
29
InstrumentationSession
sessionB;
30
public
:
31
Manager();
32
void
BeginSession(
const
std::string& name,
const
std::filesystem::path filepath =
"results.json"
);
33
void
EndSession();
34
void
AddProfile(
const
Result
& result);
35
static
Manager& Get();
36
virtual
const
InstrumentationSession
& GetAvailableSession()
const
;
37
38
std::chrono::system_clock::time_point frameStart;
39
bool
isInSession =
false
;
40
uint32_t depth;
41
};
42
43
class
Timer {
44
public
:
45
Timer(
const
char
* name);
46
~Timer();
47
void
Stop();
48
private
:
49
const
char
* name;
50
std::chrono::system_clock::time_point startTime;
51
bool
stopped;
52
};
53
}
54
}
55
56
#ifdef _DEBUG
57
#define GRIND_PROFILE_BEGIN_SESSION(name, filepath) Grindstone::Profiler::Manager::Get().BeginSession(name, filepath)
58
#define GRIND_PROFILE_END_SESSION() Grindstone::Profiler::Manager::Get().EndSession()
59
#define GRIND_PROFILE_SCOPE(name) Grindstone::Profiler::Timer grindstone_profiler_timer_##__LINE__(name)
60
#define GRIND_PROFILE_FUNC() GRIND_PROFILE_SCOPE(__FUNCSIG__)
61
#else
62
#define GRIND_PROFILE_BEGIN_SESSION(name, filepath)
63
#define GRIND_PROFILE_END_SESSION()
64
#define GRIND_PROFILE_SCOPE(name)
65
#define GRIND_PROFILE_FUNC()
66
#endif
67
68
#endif
Grindstone::Profiler::InstrumentationSession
Definition
Profiling.hpp:18
Grindstone::Profiler::Result
Definition
Profiling.hpp:11
sources
code
EngineCore
Profiling.hpp
Generated by
1.13.2