1#ifndef NNGN_TIMING_PROFILE_H
2#define NNGN_TIMING_PROFILE_H
16#define NNGN_STATS_CONTEXT(c, p) \
17 const auto NNGN_STATS_CONTEXT_VAR(__LINE__) = nngn::Profile::context<c>(p);
18#define NNGN_PROFILE_CONTEXT(p) \
19 NNGN_STATS_CONTEXT(nngn::Profile, &nngn::Profile::stats.p)
20#define NNGN_STATS_CONTEXT_VAR(l) NNGN_STATS_CONTEXT_JOIN(prof_, l)
21#define NNGN_STATS_CONTEXT_JOIN(x, y) x##y
24 std::array<uint64_t, 2>
28 static constexpr std::array
names = {
29 "schedule",
"socket",
"collision_check",
"collision_resolve",
30 "collision_lua",
"entities",
"animations",
"parents",
"renderers",
31 "renderers_debug",
"render",
"vsync",
42 static constexpr auto I = T::STATS_IDX;
43 static constexpr auto N = T::Stats::N_EVENTS;
44 std::array<uint64_t, N> *
p;
46 explicit context(std::array<uint64_t, N> *
p);
51 static Timing::duration::rep
sample();
65 if(
auto *
const op = std::exchange(this->p,
nullptr))
75 {
return nngn::Timing::clock::now().time_since_epoch().count(); }
static bool active(std::size_t i)
Definition stats.h:29
static void reserve(std::size_t i, void *p)
Definition stats.h:60
#define NNGN_MOVE_ONLY(x)
Definition utils.h:39
std::array< uint64_t, 2 > collision_lua
Definition profile.h:25
uint64_t * to_u64()
Definition profile.h:34
const uint64_t * to_u64() const
Definition profile.h:33
std::array< uint64_t, 2 > entities
Definition profile.h:26
std::array< uint64_t, 2 > renderers
Definition profile.h:26
static constexpr std::array names
Definition profile.h:28
std::array< uint64_t, 2 > render
Definition profile.h:26
std::array< uint64_t, 2 > schedule
Definition profile.h:25
std::array< uint64_t, 2 > renderers_debug
Definition profile.h:26
std::array< uint64_t, 2 > collision_resolve
Definition profile.h:25
std::array< uint64_t, 2 > collision_check
Definition profile.h:25
std::array< uint64_t, 2 > animations
Definition profile.h:26
std::array< uint64_t, 2 > vsync
Definition profile.h:27
std::array< uint64_t, 2 > parents
Definition profile.h:26
std::array< uint64_t, 2 > socket
Definition profile.h:25
std::array< uint64_t, N > * p
Definition profile.h:44
static constexpr auto I
Definition profile.h:42
~context(void)
Definition profile.h:47
context(std::array< uint64_t, N > *p)
Definition profile.h:57
static constexpr auto N
Definition profile.h:43
void end()
Definition profile.h:63
static void init()
Definition profile.h:69
static void swap()
Definition profile.h:72
static constexpr size_t STATS_IDX
Definition profile.h:39
static ProfileStats prev
Definition profile.h:50
static ProfileStats stats
Definition profile.h:50
static Timing::duration::rep sample()
Definition profile.h:74