rutz::prof Class Reference

Accumulates profiling information for a given execution context. More...

#include <rutz/prof.h>

Collaboration diagram for rutz::prof:
Collaboration graph
[legend]

List of all members.

Public Types

enum  timing_mode { WALLCLOCK, RUSAGE }
 

Different types of timing.

More...

Public Member Functions

 prof (const char *s, const char *fname, int lineno) throw ()
void reset () throw ()
 Reset the call count and elapsed time to zero.
unsigned int count () const throw ()
 Returns the number of calls since the last reset().
void add_time (const rutz::time &t) throw ()
void add_child_time (const rutz::time &t) throw ()
const char * context_name () const throw ()
const char * src_file_name () const throw ()
int src_line_no () const throw ()
double total_time () const throw ()
 Get the total elapsed time in microsecs since the last reset().
double self_time () const throw ()
 Get the total self time in microsecs since the last reset().
double avg_self_time () const throw ()
 Get the per-call average self time in microsecs since the last reset().
void print_prof_data (FILE *f) const throw ()
 Print this object's info to the given file.
void print_prof_data (std::ostream &os) const throw ()
 Print this object's info to the given stream.

Static Public Member Functions

static timing_mode get_timing_mode () throw ()
 Get the current timing_mode.
static void set_timing_mode (timing_mode mode) throw ()
 Set the current timing_mode.
static rutz::time get_now_time (timing_mode mode) throw ()
 Get the current time according to the given timing_mode.
static void print_at_exit (bool yes_or_no) throw ()
 Whether to write a profiling summary file when the program exits.
static void prof_summary_file_name (const char *fname)
 Specify the filename for the profiling summary (default is "prof.out").
static void reset_all_prof_data () throw ()
 Reset all call counts and elapsed times to zero.
static void print_all_prof_data (FILE *f) throw ()
 Print all profile data to the given file.
static void print_all_prof_data (std::ostream &os) throw ()
 Print all profile data to the given stream.

Detailed Description

Accumulates profiling information for a given execution context.

rutz::prof, along with rutz::trace and associated macros (e.g. GVX_TRACE()) form a basic profiling facility.

GVX_TRACE() statements collect timing information at function entry and exit (or, more precisely, at construction and destruction of the local object that is introduced by the GVX_TRACE() macro call). The overhead for this profiling information is non-zero, but is completely neglible in proportion to the amount of execution time taken by any of the functions in FilterOps.

To turn on profiling in a given source file, just include "rutz/trace.h" and insert a GVX_TRACE() wherever you like. To force profiling to be off, define GVX_NO_PROF before you include "rutz/trace.h".

In order to actually see the profiling information, you can either call rutz::prof::print_all_prof_data() directly, or you can call rutz::prof::print_at_exit(true). If you do the latter, then when the program exits, the profiling information will be dumped to a file named 'prof.out' in the current directory. Currently, the only program that generates a prof.out in this way is bin/invt (the tcl script interpreter).

Profiling information in prof.out looks like the following, where the first column is the average total usec per call, the second column is the number of calls, the third column is the total self usec (i.e. excluding time attributed to nested GVX_TRACE statements), the fourth column is the total self+children usec, and the remainder of the line is the function name or whatever string was passed to GVX_TRACE():

4 4500 18999 18999 xFilterClean 5 4500 23998 23998 yFilterClean 305 11600 34998 3548467 lowPassX 8 4900 42997 42997 lowPass3y 297 11600 44994 3454495 lowPassY 15 4900 77989 77989 lowPass3x 508 14700 7458831 7477830 lowPass9x 582 14700 8534732 8558730 lowPass9y 8749 4000 25762090 34996666 orientedFilter

Definition at line 89 of file prof.h.


Member Enumeration Documentation

Different types of timing.

Enumerator:
WALLCLOCK 

Track elapsed wall-clock time.

RUSAGE 

Track elpased user+sys rusage.

Definition at line 96 of file prof.h.


Member Function Documentation

double rutz::prof::avg_self_time (  )  const throw ()

Get the per-call average self time in microsecs since the last reset().

Definition at line 217 of file prof.cc.

References total_time().

unsigned int rutz::prof::count (  )  const throw ()

Returns the number of calls since the last reset().

Definition at line 172 of file prof.cc.

static rutz::time rutz::prof::get_now_time ( timing_mode  mode  )  throw () [inline, static]

Get the current time according to the given timing_mode.

Definition at line 111 of file prof.h.

References RUSAGE, rutz::time::sys_rusage(), rutz::time::user_rusage(), rutz::time::wall_clock_now(), and WALLCLOCK.

Referenced by print_prof_data(), rutz::trace::trace(), and rutz::trace::~trace().

static timing_mode rutz::prof::get_timing_mode (  )  throw () [inline, static]

Get the current timing_mode.

Definition at line 103 of file prof.h.

void rutz::prof::print_all_prof_data ( std::ostream &  os  )  throw () [static]

Print all profile data to the given stream.

Definition at line 306 of file prof.cc.

void rutz::prof::print_all_prof_data ( FILE *  f  )  throw () [static]

Print all profile data to the given file.

Definition at line 293 of file prof.cc.

Referenced by TestSuite::parseAndRun().

void rutz::prof::print_at_exit ( bool  yes_or_no  )  throw () [static]

Whether to write a profiling summary file when the program exits.

Definition at line 262 of file prof.cc.

Referenced by ModelManager::paramChanged().

void rutz::prof::print_prof_data ( std::ostream &  os  )  const throw ()

Print this object's info to the given stream.

Definition at line 240 of file prof.cc.

References get_now_time().

void rutz::prof::print_prof_data ( FILE *  f  )  const throw ()

Print this object's info to the given file.

Definition at line 222 of file prof.cc.

References get_now_time(), and GVX_ABORT.

void rutz::prof::prof_summary_file_name ( const char *  fname  )  [static]

Specify the filename for the profiling summary (default is "prof.out").

Definition at line 267 of file prof.cc.

Referenced by ModelManager::paramChanged(), and TigsJob::start2().

void rutz::prof::reset ( void   )  throw ()

Reset the call count and elapsed time to zero.

Definition at line 165 of file prof.cc.

References rutz::time::reset().

Referenced by reset_all_prof_data().

void rutz::prof::reset_all_prof_data (  )  throw () [static]

Reset all call counts and elapsed times to zero.

Definition at line 277 of file prof.cc.

References reset().

double rutz::prof::self_time (  )  const throw ()

Get the total self time in microsecs since the last reset().

Definition at line 210 of file prof.cc.

References rutz::time::usec().

static void rutz::prof::set_timing_mode ( timing_mode  mode  )  throw () [inline, static]

Set the current timing_mode.

Definition at line 107 of file prof.h.

Referenced by ModelManager::paramChanged().

double rutz::prof::total_time (  )  const throw ()

Get the total elapsed time in microsecs since the last reset().

Definition at line 203 of file prof.cc.

References rutz::time::usec().

Referenced by avg_self_time().


The documentation for this class was generated from the following files:
Generated on Sun May 8 08:44:44 2011 for iLab Neuromorphic Vision Toolkit by  doxygen 1.6.3