Darwin
1.10(beta)
|
Static class for providing profile information on functions. More...
Static Public Member Functions | |
static int | getHandle (const char *name) |
return a handle for profiling a code block called name | |
static void | clear () |
clear all profiling information | |
static void | clear (int handle) |
clear all profiling information for handle | |
static void | tic (int handle) |
starting timing execution of handle | |
static void | toc (int handle) |
stop timing execution of handle (and update number of calls) | |
static double | walltime (int handle) |
return total real-world running time of handle (in seconds) | |
static double | time (int handle) |
return total CPU running time of handle (in seconds) | |
static int | calls (int handle) |
return number of times handle has been profiled | |
static void | print () |
display profile information for all handles (to message logger) | |
Static Public Attributes | |
static bool | enabled = false |
set true to enable profiling | |
Static class for providing profile information on functions.
drwnCodeProfiler is typically used to accumulate information on entire functions (or within subroutines). Wrap the function or code block in
to accumulate timing and number of calls for a given function. The timer accumulates the amount of processor and real (wall clock) time used between tic and toc calls (child processes, such as file I/O, are not counted in this time). Processor times may be inaccurate for functions that take longer than about 1 hour.
By default profiling is turned off and must be enabled in main() with
Most Darwin applications use the standard command line option -profile to enable profiling. Call the function drwnCodeProfiler::print()
before exiting main() to log profiling information.
The code can also be used to setting time limits or recursive call limits within instrumented functions. Use time and calls to get the total running time or total number of calls for a given handle.
The macros DRWN_FCN_TIC and DRWN_FCN_TOC can be used at the entry and exit of your functions to instrument the entire function. Make sure you put DRWN_FCN_TOC before all return statements within the function.