MOOCHO (Single Doxygen Collection) Version of the Day
Public Member Functions | Private Member Functions | Private Attributes
ProfileHackPack::ProfileTiming Class Reference

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 ()
 

Private Member Functions

 ProfileTiming ()
 ProfileTiming (const ProfileTiming &)
ProfileTimingoperator= (const ProfileTiming &)

Private Attributes

std::string func_name_
 
std::ostream * out_
StopWatchPack::stopwatch timer_

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 123 of file ProfileHackPack_profile_hack.hpp.


Constructor & Destructor Documentation

ProfileHackPack::ProfileTiming::ProfileTiming ( const std::string &  func_name,
std::ostream *  out = NULL 
) [inline]
Parameters:
func_nameThe name of the function to be timed
outIf != NULL then the function times will be printed to this stream when object is destroyed.

Definition at line 131 of file ProfileHackPack_profile_hack.hpp.

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

Definition at line 138 of file ProfileHackPack_profile_hack.hpp.

ProfileHackPack::ProfileTiming::ProfileTiming ( ) [private]
ProfileHackPack::ProfileTiming::ProfileTiming ( const ProfileTiming ) [private]

Member Function Documentation

ProfileTiming& ProfileHackPack::ProfileTiming::operator= ( const ProfileTiming ) [private]

Member Data Documentation

Definition at line 147 of file ProfileHackPack_profile_hack.hpp.

std::ostream* ProfileHackPack::ProfileTiming::out_ [private]

Definition at line 148 of file ProfileHackPack_profile_hack.hpp.

Definition at line 149 of file ProfileHackPack_profile_hack.hpp.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines