3 //==========================================================================
5 * @file Profile_Timer.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
9 //==========================================================================
12 #ifndef ACE_PROFILE_TIMER_H
13 #define ACE_PROFILE_TIMER_H
14 #include /**/ "ace/pre.h"
16 #include /**/ "ace/config-all.h"
18 #if !defined (ACE_LACKS_PRAGMA_ONCE)
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/High_Res_Timer.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
27 * @class ACE_Profile_Timer
29 * @brief This class provides both a timing mechanism and a mechanism
30 * for reporting the resource usage of a process.
32 class ACE_Export ACE_Profile_Timer
36 * @class ACE_Elapsed_Time
38 * @brief Keeps track of the various user, system, and elapsed (real)
41 class ACE_Elapsed_Time
44 /// Elapsed wall clock time.
45 ACE_timer_t real_time
;
47 /// CPU time spent in user space.
48 ACE_timer_t user_time
;
50 /// CPU time spent in system space.
51 ACE_timer_t system_time
;
54 typedef ACE_Rusage Rusage
;
56 /// Default constructor. Clears all time values to 0.
59 /// Shutdown the timer.
60 ~ACE_Profile_Timer ();
63 /// Activate the timer.
69 // = Resource utilization methods.
70 /// Compute the time elapsed between calls to @c start() and @c stop().
71 int elapsed_time (ACE_Elapsed_Time
&et
);
73 /// Compute the amount of resource utilization between calls to @c start()
75 void elapsed_rusage (ACE_Profile_Timer::Rusage
&rusage
);
77 /// Return the resource utilization (don't recompute it).
78 void get_rusage (ACE_Profile_Timer::Rusage
&rusage
);
80 /// Dump the state of an object.
83 /// Declare the dynamic allocation hooks.
84 ACE_ALLOC_HOOK_DECLARE
;
87 /// Compute how much time has elapsed.
88 void compute_times (ACE_Elapsed_Time
&et
);
90 /// Keep track of the starting resource utilization.
91 ACE_Profile_Timer::Rusage begin_usage_
;
93 /// Keep track of the ending resource utilization.
94 ACE_Profile_Timer::Rusage end_usage_
;
96 /// Keep track of the last rusage for incremental timing.
97 ACE_Profile_Timer::Rusage last_usage_
;
99 #if defined (ACE_HAS_GETRUSAGE)
100 /// Subtract two timestructs and store their difference.
101 void subtract (timeval
&tdiff
,
105 /// Keep track of the beginning time.
108 /// Keep track of the ending time.
111 /// Keep track of the last time for incremental timing.
113 #endif /* ACE_HAS_GETRUSAGE */
115 #if defined (ACE_WIN32) || !defined (ACE_HAS_GETRUSAGE)
116 /// The high resolution timer
117 ACE_High_Res_Timer timer_
;
118 #endif /* ACE_WIN32 || !ACE_HAS_GETRUSAGE */
121 ACE_END_VERSIONED_NAMESPACE_DECL
123 #if defined (__ACE_INLINE__)
124 # include "ace/Profile_Timer.inl"
125 #endif /* __ACE_INLINE__ */
127 #include /**/ "ace/post.h"
128 #endif /* ACE_PROFILE_TIMER_H */