Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / Profile_Timer.h
blob9419f19c50594ea649fd3e72d12f9d0a45ab3c2b
1 // -*- C++ -*-
3 //==========================================================================
4 /**
5 * @file Profile_Timer.h
7 * @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
8 */
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)
19 # pragma once
20 #endif /* ACE_LACKS_PRAGMA_ONCE */
22 #include "ace/High_Res_Timer.h"
24 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
26 /**
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
34 public:
35 /**
36 * @class ACE_Elapsed_Time
38 * @brief Keeps track of the various user, system, and elapsed (real)
39 * times.
41 class ACE_Elapsed_Time
43 public:
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.
57 ACE_Profile_Timer ();
59 /// Shutdown the timer.
60 ~ACE_Profile_Timer ();
62 // = Timer methods.
63 /// Activate the timer.
64 int start ();
66 /// Stop the timer.
67 int stop ();
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()
74 /// and @c stop().
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.
81 void dump () const;
83 /// Declare the dynamic allocation hooks.
84 ACE_ALLOC_HOOK_DECLARE;
86 private:
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,
102 timeval &t0,
103 timeval &t1);
105 /// Keep track of the beginning time.
106 timeval begin_time_;
108 /// Keep track of the ending time.
109 timeval end_time_;
111 /// Keep track of the last time for incremental timing.
112 timeval last_time_;
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 */