NcEngine
Profile.h
Go to the documentation of this file.
1
5#pragma once
6
7#ifdef NC_PROFILING_ENABLED
8
9#if defined(NC_USE_TRACY)
10
11#include "tracy/Tracy.hpp"
12
13namespace nc
14{
16namespace detail
17{
18struct TaskMeasurement
19{
20 explicit TaskMeasurement()
21 {
22 tracy::SetThreadName("NcEngine Worker");
23 }
24
25 ~TaskMeasurement() noexcept = default;
26};
27} // namespace detail
28} // namespace nc
32#define NC_PROFILE_FRAME(name) FrameMark
33
35#define NC_PROFILE_SCOPE(name, category) ZoneScopedN(name)
36
38#define NC_PROFILE_TASK(name, category) \
39 const auto _ncTaskMeasurement ## __LINE__ = nc::detail::TaskMeasurement{}; \
40 NC_PROFILE_SCOPE(name, category)
41
42#elif defined(NC_USE_OPTICK)
43
44#include "optick.h"
45
46namespace nc
47{
48using ProfileCategory = Optick::Category;
49
51namespace detail
52{
53struct TaskMeasurement
54{
55 explicit TaskMeasurement()
56 {
57 OPTICK_START_THREAD("NcEngine Worker");
58 }
59
60 ~TaskMeasurement() noexcept
61 {
62 OPTICK_STOP_THREAD();
63 }
64};
65} // namespace detail
66} // namespace nc
70#define NC_PROFILE_FRAME(name) OPTICK_FRAME(name)
71
73#define NC_PROFILE_SCOPE(name, category) OPTICK_CATEGORY(name, category)
74
76#define NC_PROFILE_TASK(name, category) \
77 const auto _ncTaskMeasurement ## __LINE__ = nc::detail::TaskMeasurement{}; \
78 NC_PROFILE_SCOPE(name, category)
79
80#endif // NC_USE_TRACY / NC_USE_OPTICK
81
82#else // NC_PROFILING_ENABLED not defined
83
84#define NC_PROFILE_FRAME(name)
85#define NC_PROFILE_SCOPE(name, category)
86#define NC_PROFILE_TASK(name, category)
87
88#endif // NC_PROFILING_ENABLED