ProfileHackPack::ProfileTiming Class Reference
[Poor-mans profiling helper tools.]

Helper class that takes care of timing. More...

#include <ProfileHackPack_profile_hack.hpp>

List of all members.

Public Member Functions

 ProfileTiming (const std::string &func_name, std::ostream *out=NULL)
 ~ProfileTiming ()
 


Detailed Description

Helper class that takes care of timing.

Here is a simple program that uses these this class:

 #include <iostream>

 int main() {
 #ifdef USE_PROFILE_HACK
     ProfileHackPack::ProfileTiming profile_timing("main()",&std::cout);
 #endif
     for( int i = 0; i < 10; ++i ) {
       f();
       g();
     }
     return 0;
     // When main() exists, the destructor for profile_timing will 
     // record the time and will print the total times and number of
   // calls for "main()", "f()" and "g()" to <tt>std::cout</tt>.
 }

 void f() {
 #ifdef USE_PROFILE_HACK
     ProfileHackPack::ProfileTiming profile_timing("f()");
 #endif
     ...
     //  When f() exists, the destructor for profile_timing will record the
     // time for this function call and increment the number of calls to this
     // function.
 }

 void g() {
 #ifdef USE_PROFILE_HACK
     ProfileHackPack::ProfileTiming profile_timing("g()");
 #endif
     ...
     //  When g() exists, the destructor for profile_timing will record the
     // time for this function call and increment the number of calls to this
     // function.
 }

 

ToDo: Show an example of the output that might be generated for the above program.

In the above program, if USE_PROFILE_HACK is not defined, then there will be no runtime performance penalty and no profiling results will be printed.

This class collects timings for an entire process and should work properly in a multi-threaded application.

Definition at line 110 of file ProfileHackPack_profile_hack.hpp.


Constructor & Destructor Documentation

ProfileHackPack::ProfileTiming::ProfileTiming ( const std::string &  func_name,
std::ostream *  out = NULL 
) [inline]

Parameters:
func_name The name of the function to be timed
out If != NULL then the function times will be printed to this stream when object is destroyed.

Definition at line 118 of file ProfileHackPack_profile_hack.hpp.

ProfileHackPack::ProfileTiming::~ProfileTiming (  )  [inline]

Definition at line 125 of file ProfileHackPack_profile_hack.hpp.


The documentation for this class was generated from the following file:
Generated on Wed May 12 21:50:27 2010 for MoochoPack: Miscellaneous Utilities for MOOCHO by  doxygen 1.4.7