29#if NEBULA_ENABLE_PROFILING
30#define N_SCOPE(name, cat) Profiling::ProfilingScopeLock __##name##cat##scope__(#name, #cat, __FILE__, __LINE__);
31#define N_SCOPE_DYN(str, cat) Profiling::ProfilingScopeLock __dynscope##cat##__(str, #cat, __FILE__, __LINE__);
32#define N_SCOPE_ACCUM(name, cat) Profiling::ProfilingScopeLock __##name##cat##scope__(#name, #cat, __FILE__, __LINE__, true);
33#define N_SCOPE_DYN_ACCUM(name, cat) Profiling::ProfilingScopeLock __##name##cat##scope__(#name, #cat, __FILE__, __LINE__, true);
34#define N_MARKER_BEGIN(name, cat) { Profiling::ProfilingScope __##name##cat##scope__ = {#name, #cat, __FILE__, __LINE__, false}; Profiling::ProfilingPushScope(__##name##cat##scope__); }
35#define N_MARKER_DYN_BEGIN(str, cat) { Profiling::ProfilingScope __dynmarker##cat##__ = {str, #cat, __FILE__, __LINE__, false}; Profiling::ProfilingPushScope(__dynmarker##cat##__); }
36#define N_MARKER_END() { Profiling::ProfilingPopScope(); }
37#define N_COUNTER_INCR(name, value) Profiling::ProfilingIncreaseCounter(name, value);
38#define N_COUNTER_DECR(name, value) Profiling::ProfilingDecreaseCounter(name, value);
39#define N_BUDGET_COUNTER_SETUP(name, budget) Profiling::ProfilingSetupBudgetCounter(name, budget);
40#define N_BUDGET_COUNTER_INCR(name, value) Profiling::ProfilingBudgetIncreaseCounter(name, value);
41#define N_BUDGET_COUNTER_DECR(name, value) Profiling::ProfilingBudgetDecreaseCounter(name, value);
42#define N_BUDGET_COUNTER_RESET(name) Profiling::ProfilingBudgetResetCounter(name);
43#define N_DECLARE_COUNTER(name, label) static const char* name = #label;
45#define N_SCOPE(name, cat)
46#define N_SCOPE_DYN(str, cat)
47#define N_SCOPE_ACCUM(name, cat)
48#define N_SCOPE_DYN_ACCUM(name, cat)
49#define N_MARKER_BEGIN(name, cat)
51#define N_COUNTER_INCR(name, value)
52#define N_COUNTER_DECR(name, value)
53#define N_DECLARE_COUNTER(name, label)
60struct ProfilingContext;
Critical section objects are used to protect a portion of code from parallel execution.
A timer object is the most basic object for time measurement.
Nebula's dynamic array class.
Definition array.h:60
A collection of key/value pairs with quick value retrieval by key at roughly O(log n).
Definition dictionary.h:34
Nebula's stack class (a FILO container).
Definition stack.h:19
A StringAtom.
Definition stringatom.h:22
Definition profiling.cc:9
const Util::Dictionary< const char *, Util::Pair< uint64, uint64 > > & ProfilingGetBudgetCounters()
Return set of budget counters.
Definition profiling.cc:257
void ProfilingSetupBudgetCounter(const char *id, uint64 budget)
Setup a profiling budget counter.
Definition profiling.cc:206
void ProfilingNewFrame()
pushes an 'end of frame' marker, only available on the main thread
Definition profiling.cc:84
void ProfilingClear()
clear all scopes
Definition profiling.cc:150
const Util::Dictionary< const char *, uint64 > & ProfilingGetCounters()
return table of counters
Definition profiling.cc:197
void ProfilingIncreaseCounter(const char *id, uint64 value)
increment profiling counter
Definition profiling.cc:167
void ProfilingBudgetIncreaseCounter(const char *id, uint64 value)
Increment budget counter.
Definition profiling.cc:222
Threading::AtomicCounter ProfilingContextCounter
atomic counter used to give each thread a unique id
Definition profiling.cc:15
void ProfilingPopScope()
pop scope from scope stack
Definition profiling.cc:38
Util::Dictionary< const char *, uint64 > counters
Definition profiling.cc:160
const Util::Array< ProfilingContext > ProfilingGetContexts()
get all profiling contexts
Definition profiling.cc:141
void ProfilingBudgetResetCounter(const char *id)
Reset budget counter.
Definition profiling.cc:244
Threading::CriticalSection counterLock
Definition profiling.cc:159
const Util::Array< ProfilingScope > & ProfilingGetScopes(Threading::ThreadId thread)
get all top level scopes based on thread, only run when you know the thread is finished
Definition profiling.cc:128
void ProfilingDecreaseCounter(const char *id, uint64 value)
decrement profiling counter
Definition profiling.cc:184
Util::Array< Threading::CriticalSection * > contextMutexes
Definition profiling.cc:12
Util::Dictionary< const char *, Util::Pair< uint64, uint64 > > budgetCounters
Definition profiling.cc:161
Util::Dictionary< Util::StringAtom, Util::Array< ProfilingScope > > scopesByCategory
Definition profiling.cc:13
void ProfilingBudgetDecreaseCounter(const char *id, uint64 value)
Decrement budget counter.
Definition profiling.cc:233
Threading::CriticalSection categoryLock
Definition profiling.cc:14
void ProfilingRegisterThread()
register a new thread for the profiling
Definition profiling.cc:114
void ProfilingPushScope(const ProfilingScope &scope)
push scope to scope stack
Definition profiling.cc:22
Util::Array< ProfilingContext > profilingContexts
Definition profiling.cc:11
Timing::Time ProfilingGetTime()
get current frametime
Definition profiling.cc:103
The Jobs2 system provides a set of threads and a pool of jobs from which threads can pickup work.
Definition jobs2.h:16
pthread_t ThreadId
Definition linuxthreadid.h:15
volatile int AtomicCounter
Definition interlocked.h:19
double Time
the time datatype
Definition time.h:18
thread context of profiling
Definition profiling.h:170
Timing::Timer timer
Definition profiling.h:178
Util::Stack< ProfilingScope > scopes
Definition profiling.h:175
Util::StringAtom threadName
Definition profiling.h:179
ProfilingContext()
Definition profiling.h:171
Threading::ThreadId threadId
Definition profiling.h:180
Util::Array< ProfilingScope > topLevelScopes
Definition profiling.h:176
Definition profiling.h:112
Util::StringAtom category
Definition profiling.h:136
const char * file
Definition profiling.h:137
bool accum
Definition profiling.h:139
ProfilingScope()
default constructor
Definition profiling.h:114
const char * name
Definition profiling.h:135
ProfilingScope(const char *name, Util::StringAtom category, const char *file, int line, bool accum)
constructor
Definition profiling.h:125
Timing::Time duration
Definition profiling.h:142
int line
Definition profiling.h:138
Timing::Time start
Definition profiling.h:141
Util::Array< ProfilingScope > children
Definition profiling.h:143
convenience class used to automatically push and pop scopes
Definition profiling.h:148
ProfilingScopeLock(const char *name, Util::StringAtom category, const char *file, int line, bool accum=false)
constructor
Definition profiling.h:150
~ProfilingScopeLock()
destructor
Definition profiling.h:161
ProfilingScope scope
Definition profiling.h:165
Typedefs for the Timing subsystem.
uint64_t uint64
Definition types.h:36