Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

PLearn::Profiler Class Reference

#include <Profiler.h>

Collaboration diagram for PLearn::Profiler:

Collaboration graph
[legend]
List of all members.

Static Public Member Functions

void activate ()
void disactivate ()
void start (const string &name_of_piece_of_code)
 start recording time for named piece of code

void end (const string &name_of_piece_of_code)
 end recording time for named piece of code, and increment frequency of occurence and total duration of this piece of code.

void report (ostream &out)
 output a report on the output stream, giving the statistics recorded for each of the named pieces of codes.


Static Protected Attributes

map< string, Statscodes_statistics
tms t
bool active = false

Detailed Description

Profiling tools, to count average time elapsed and number of times traversed for pieces of code delimited by two calls to the static functions

Profiler::start("name_of_piece_of_code"); ... Profiler::end("name_of_piece_of_code");

A static field of Profiler is used to maintain the statistics of occurence and durations for each piece of code. Calls to start/end for the same name cannot be nested.

Before the above calls, usually in the main program, the user must call

Profiler::activate();

and after all the above calls, a report for all such pieces of code can then be obtained by calling

Profiler::report(cout);

on an output stream.

This code is based on statistical averaging (using the C "times" function) because the individual measurements of elapsed time with times are too coarse (e.g. 100th of a second).

Definition at line 89 of file Profiler.h.


Member Function Documentation

void PLearn::Profiler::activate  )  [inline, static]
 

Definition at line 106 of file Profiler.h.

References active.

void PLearn::Profiler::disactivate  )  [inline, static]
 

Definition at line 107 of file Profiler.h.

References active.

void PLearn::Profiler::end const string name_of_piece_of_code  )  [static]
 

end recording time for named piece of code, and increment frequency of occurence and total duration of this piece of code.

Definition at line 81 of file Profiler.cc.

References active, codes_statistics, PLearn::Profiler::Stats::frequency_of_occurence, PLearn::Profiler::Stats::on_going, PLERROR, PLWARNING, t, PLearn::Profiler::Stats::time_of_last_start, PLearn::times(), and PLearn::Profiler::Stats::total_duration.

Referenced by report().

void PLearn::Profiler::report ostream &  out  )  [static]
 

output a report on the output stream, giving the statistics recorded for each of the named pieces of codes.

Definition at line 107 of file Profiler.cc.

References codes_statistics, end(), PLearn::endl(), PLearn::Profiler::Stats::frequency_of_occurence, and PLearn::Profiler::Stats::total_duration.

void PLearn::Profiler::start const string name_of_piece_of_code  )  [static]
 

start recording time for named piece of code

Definition at line 52 of file Profiler.cc.

References PLearn::Profiler::Stats::on_going, PLERROR, PLearn::Profiler::Stats::time_of_last_start, and PLearn::times().


Member Data Documentation

bool PLearn::Profiler::active = false [static, protected]
 

Definition at line 48 of file Profiler.cc.

Referenced by activate(), disactivate(), and end().

map< string, Profiler::Stats > PLearn::Profiler::codes_statistics [static, protected]
 

Definition at line 46 of file Profiler.cc.

Referenced by end(), and report().

struct tms PLearn::Profiler::t [static, protected]
 

Definition at line 131 of file Profiler.h.

Referenced by end().


The documentation for this class was generated from the following files:
Generated on Tue Aug 17 16:24:35 2004 for PLearn by doxygen 1.3.7