Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Profile_Timer Class Reference

This class provides both a timing mechanism and a mechanism for reporting the resource usage of a process. More...

#include <Profile_Timer.h>

Collaboration diagram for ACE_Profile_Timer:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Rusage Rusage

Public Methods

 ACE_Profile_Timer (void)
 Default constructor. Clears all time values to 0. More...

 ~ACE_Profile_Timer (void)
 Shutdown the timer. More...

int start (void)
 Activate the timer. More...

int stop (void)
 Stop the timer. More...

int elapsed_time (ACE_Elapsed_Time &et)
 Compute the time elapsed between calls to start() and stop(). More...

void elapsed_rusage (ACE_Profile_Timer::Rusage &rusage)
 Compute the amount of resource utilization between calls to start() and stop(). More...

void get_rusage (ACE_Profile_Timer::Rusage &rusage)
 Return the resource utilization (don't recompute it). More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Private Methods

void compute_times (ACE_Elapsed_Time &et)
 Compute how much time has elapsed. More...


Private Attributes

ACE_Profile_Timer::Rusage begin_usage_
 Keep track of the starting resource utilization. More...

ACE_Profile_Timer::Rusage end_usage_
 Keep track of the ending resource utilization. More...

ACE_Profile_Timer::Rusage last_usage_
 Keep track of the last rusage for incremental timing. More...

ACE_High_Res_Timer timer_
 The high resolution timer. More...


Detailed Description

This class provides both a timing mechanism and a mechanism for reporting the resource usage of a process.

Definition at line 33 of file Profile_Timer.h.


Member Typedef Documentation

typedef ACE_Rusage ACE_Profile_Timer::Rusage
 

Definition at line 59 of file Profile_Timer.h.

Referenced by elapsed_rusage, and get_rusage.


Constructor & Destructor Documentation

ACE_Profile_Timer::ACE_Profile_Timer void   
 

Default constructor. Clears all time values to 0.

Definition at line 269 of file Profile_Timer.cpp.

References ACE_TRACE, and ACE_OS_String::memset.

00270   : timer_ ()
00271 {
00272   ACE_TRACE ("ACE_Profile_Timer::ACE_Profile_Timer");
00273 #  if defined (ACE_HAS_GETRUSAGE)
00274 
00275   ACE_OS::memset (&this->end_usage_, 0, sizeof this->end_usage_);
00276   ACE_OS::memset (&this->begin_usage_, 0, sizeof this->begin_usage_);
00277   ACE_OS::memset (&this->last_usage_, 0, sizeof this->last_usage_);
00278 
00279   ACE_OS::memset (&this->begin_time_, 0, sizeof this->begin_time_);
00280   ACE_OS::memset (&this->end_time_, 0, sizeof this->end_time_);
00281   ACE_OS::memset (&this->last_time_, 0, sizeof this->last_time_);
00282 #  endif /* ACE_HAS_GETRUSAGE */
00283 }

ACE_INLINE ACE_Profile_Timer::~ACE_Profile_Timer void   
 

Shutdown the timer.

Definition at line 100 of file Profile_Timer.i.

00101 {
00102 }


Member Function Documentation

void ACE_Profile_Timer::compute_times ACE_Elapsed_Time   et [private]
 

Compute how much time has elapsed.

void ACE_Profile_Timer::dump void    const
 

Dump the state of an object.

Definition at line 262 of file Profile_Timer.cpp.

References ACE_TRACE, ACE_High_Res_Timer::dump, and timer_.

00263 {
00264   ACE_TRACE ("ACE_Profile_Timer::dump");
00265   timer_.dump ();
00266 }

void ACE_Profile_Timer::elapsed_rusage ACE_Profile_Timer::Rusage   rusage
 

Compute the amount of resource utilization between calls to start() and stop().

Definition at line 329 of file Profile_Timer.cpp.

References ACE_TRACE, begin_usage_, end_usage_, and Rusage.

00330 {
00331   ACE_TRACE ("ACE_Profile_Timer::elapsed_rusage");
00332 
00333 #  if defined (ACE_HAS_GETRUSAGE)
00334   usage.ru_utime =
00335     this->end_usage_.ru_utime - this->begin_usage_.ru_utime;
00336   usage.ru_stime =
00337     this->end_usage_.ru_stime - this->begin_usage_.ru_stime;
00338 #  else /* ACE_HAS_GETRUSAGE */
00339   usage = 0;
00340 #  endif /* ACE_HAS_GETRUSAGE */
00341 }

int ACE_Profile_Timer::elapsed_time ACE_Elapsed_Time   et
 

Compute the time elapsed between calls to start() and stop().

Definition at line 286 of file Profile_Timer.cpp.

References ACE_hrtime_t, ACE_ONE_SECOND_IN_NSECS, ACE_ONE_SECOND_IN_USECS, ACE_TRACE, ACE_High_Res_Timer::elapsed_time, ACE_Time_Value::sec, timer_, and ACE_Time_Value::usec.

00287 {
00288   ACE_TRACE ("ACE_Profile_Timer::elapsed_time");
00289 
00290   ACE_hrtime_t delta_t; // nanoseconds
00291   timer_.elapsed_time (delta_t);
00292 #  if defined (ACE_LACKS_LONGLONG_T)
00293   et.real_time = delta_t / (double) ACE_ONE_SECOND_IN_NSECS;
00294 #  else
00295   et.real_time = (__int64) delta_t / (double) ACE_ONE_SECOND_IN_NSECS;
00296 #  endif /* ACE_LACKS_LONGLONG_T */
00297 #  if defined (ACE_HAS_GETRUSAGE)
00298   ACE_Time_Value atv = ACE_Time_Value (this->end_usage_.ru_utime)
00299                        - ACE_Time_Value (this->begin_usage_.ru_utime);
00300   et.user_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS;
00301 
00302   atv = ACE_Time_Value (this->end_usage_.ru_stime)
00303         - ACE_Time_Value (this->begin_usage_.ru_stime);
00304   et.system_time = atv.sec () + ((double) atv.usec ()) / ACE_ONE_SECOND_IN_USECS;
00305 #  else /* ACE_HAS_GETRUSAGE */
00306   et.user_time = 0;
00307   et.system_time = 0;
00308 #  endif /* ACE_HAS_GETRUSAGE */
00309 
00310   return 0;
00311 }

void ACE_Profile_Timer::get_rusage ACE_Profile_Timer::Rusage   rusage
 

Return the resource utilization (don't recompute it).

Definition at line 316 of file Profile_Timer.cpp.

References ACE_TRACE, end_usage_, and Rusage.

00317 {
00318   ACE_TRACE ("ACE_Profile_Timer::get_rusage");
00319 #  if defined (ACE_HAS_GETRUSAGE)
00320   usage = this->end_usage_;
00321 #  else /* ACE_HAS_GETRUSAGE */
00322   usage = 0;
00323 #  endif /* ACE_HAS_GETRUSAGE */
00324 }

ACE_INLINE int ACE_Profile_Timer::start void   
 

Activate the timer.

Definition at line 84 of file Profile_Timer.i.

References ACE_TRACE, ACE_High_Res_Timer::start, and timer_.

00085 {
00086   ACE_TRACE ("ACE_Profile_Timer::start");
00087   this->timer_.start ();
00088   return 0;
00089 }

ACE_INLINE int ACE_Profile_Timer::stop void   
 

Stop the timer.

Definition at line 92 of file Profile_Timer.i.

References ACE_TRACE, ACE_High_Res_Timer::stop, and timer_.

00093 {
00094   ACE_TRACE ("ACE_Profile_Timer::stop");
00095   this->timer_.stop ();
00096   return 0;
00097 }


Member Data Documentation

ACE_Profile_Timer::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 90 of file Profile_Timer.h.

ACE_Profile_Timer::Rusage ACE_Profile_Timer::begin_usage_ [private]
 

Keep track of the starting resource utilization.

Definition at line 97 of file Profile_Timer.h.

Referenced by elapsed_rusage.

ACE_Profile_Timer::Rusage ACE_Profile_Timer::end_usage_ [private]
 

Keep track of the ending resource utilization.

Definition at line 100 of file Profile_Timer.h.

Referenced by elapsed_rusage, and get_rusage.

ACE_Profile_Timer::Rusage ACE_Profile_Timer::last_usage_ [private]
 

Keep track of the last rusage for incremental timing.

Definition at line 103 of file Profile_Timer.h.

ACE_High_Res_Timer ACE_Profile_Timer::timer_ [private]
 

The high resolution timer.

Definition at line 130 of file Profile_Timer.h.

Referenced by dump, elapsed_time, start, and stop.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:54:34 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002