Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
|
Go to the source code of this file.
Classes | |
class | ScopeTimer |
used by TIMER More... | |
class | TimerUnit |
struct | TimerClient |
class | ScopeTimerAccrue |
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... | |
Typedefs | |
typedef i64 | Cycles |
Functions | |
void | timer_Init () |
timer_Time will subsequently return values relative to the current time. More... | |
double | timer_Time () |
double | timer_Resolution () |
std::string | StringForSeconds (double seconds) |
internal helper functions for returning an easily readable string (i.e. More... | |
std::string | StringForCycles (Cycles cycles) |
TimerClient * | timer_AddClient (TimerClient *tc, const wchar_t *description) |
make the given TimerClient (usually instantiated as static data) ready for use. More... | |
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_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 }
#define TIMER_END | ( | description | ) | } |
std::string StringForCycles | ( | Cycles | cycles | ) |
std::string StringForSeconds | ( | double | seconds | ) |
internal helper functions for returning an easily readable string (i.e.
re-scaled to appropriate units)
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:
void timer_DisplayClientTotals | ( | ) |
display all clients' totals; does not reset them.
typically called at exit.
void timer_Init | ( | ) |
timer_Time will subsequently return values relative to the current time.
double timer_Resolution | ( | ) |
double timer_Time | ( | ) |