Pyrogenesis
13997
|
Go to the source code of this file.
Classes | |
class | ScopeTimer |
used by TIMER More... | |
class | TimerUnit |
struct | TimerClient |
struct | BillingPolicy_Default |
bill the difference between t0 and t1 to the client's total. More... | |
struct | BillingPolicy_Atomic |
thread-safe (not used by default due to its higher overhead) note: we can't just use thread-local variables to avoid synchronization overhead because we don't have control over all threads (for accumulating their separate timer copies). More... | |
class | ScopeTimerAccrue< BillingPolicy > |
used by TIMER_ACCRUE More... | |
Macros | |
#define | TIMER(description) ScopeTimer UID__(description) |
Measures the time taken to execute code up until end of the current scope; displays it via debug_printf. More... | |
#define | TIMER_BEGIN(description) { ScopeTimer UID__(description) |
Measures the time taken to execute code between BEGIN and END markers; displays it via debug_printf. More... | |
#define | TIMER_END(description) } |
#define | TIMER_ADD_CLIENT(id) |
"allocate" a new TimerClient that will keep track of the total time billed to it, along with a description string. More... | |
#define | TIMER_ACCRUE(client) ScopeTimerAccrue<> UID__(client) |
Measure the time taken to execute code up until end of the current scope; bill it to the given TimerClient object. More... | |
#define | TIMER_ACCRUE_ATOMIC(client) ScopeTimerAccrue<BillingPolicy_Atomic> UID__(client) |
Typedefs | |
typedef i64 | Cycles |
Functions | |
LIB_API void | timer_LatchStartTime () |
timer_Time will subsequently return values relative to the current time. More... | |
LIB_API double | timer_Time () |
LIB_API double | timer_Resolution () |
LIB_API std::wstring | StringForSeconds (double seconds) |
internal helper functions for returning an easily readable string (i.e. More... | |
LIB_API std::wstring | StringForCycles (Cycles cycles) |
LIB_API TimerClient * | timer_AddClient (TimerClient *tc, const wchar_t *description) |
make the given TimerClient (usually instantiated as static data) ready for use. More... | |
LIB_API void | timer_DisplayClientTotals () |
display all clients' totals; does not reset them. More... | |
#define TIMER | ( | description | ) | ScopeTimer UID__(description) |
Measures the time taken to execute code up until end of the current scope; displays it via debug_printf.
Can safely be nested. Useful for measuring time spent in a function or basic block. must remain valid over the lifetime of this object; a string literal is safest.
Example usage: void func() { TIMER(L"description"); // code to be measured }
#define TIMER_ACCRUE | ( | client | ) | ScopeTimerAccrue<> UID__(client) |
Measure the time taken to execute code up until end of the current scope; bill it to the given TimerClient object.
Can safely be nested. Useful for measuring total time spent in a function or basic block over the entire program. `client' is an identifier registered via TIMER_ADD_CLIENT.
Example usage: TIMER_ADD_CLIENT(client);
void func() { TIMER_ACCRUE(client); // code to be measured }
[later or at exit] timer_DisplayClientTotals();
#define TIMER_ACCRUE_ATOMIC | ( | client | ) | ScopeTimerAccrue<BillingPolicy_Atomic> UID__(client) |
#define TIMER_ADD_CLIENT | ( | id | ) |
"allocate" a new TimerClient that will keep track of the total time billed to it, along with a description string.
These are displayed when timer_DisplayClientTotals is called. Invoke this at file or function scope; a (static) TimerClient pointer of name <id> will be defined, which should be passed to TIMER_ACCRUE.
#define TIMER_BEGIN | ( | description | ) | { ScopeTimer UID__(description) |
Measures the time taken to execute code between BEGIN and END markers; displays it via debug_printf.
Can safely be nested. Useful for measuring several pieces of code within the same function/block. must remain valid over the lifetime of this object; a string literal is safest.
Caveats:
Example usage: void func2() { // uninteresting code TIMER_BEGIN(L"description2"); // code to be measured TIMER_END(L"description2"); // uninteresting code }
LIB_API std::wstring StringForSeconds | ( | double | seconds | ) |
LIB_API TimerClient* timer_AddClient | ( | TimerClient * | tc, |
const wchar_t * | description | ||
) |
make the given TimerClient (usually instantiated as static data) ready for use.
returns its address for TIMER_ADD_CLIENT's convenience. this client's total (which is increased by a BillingPolicy) will be displayed by timer_DisplayClientTotals. notes:
LIB_API void timer_DisplayClientTotals | ( | ) |
LIB_API void timer_LatchStartTime | ( | ) |
LIB_API double timer_Resolution | ( | ) |