Fixed typos
[ACE_TAO.git] / ACE / ace / Profile_Timer.h
bloba28376d44d401d120637225cd33a38877893c5a0
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 (void);
59 /// Shutdown the timer.
60 ~ACE_Profile_Timer (void);
62 // = Timer methods.
63 /// Activate the timer.
64 int start (void);
66 /// Stop the timer.
67 int stop (void);
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 (void) 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_PRUSAGE_T)
100 /// Subtract two timestructs and store their difference.
101 void subtract (timespec_t &tdiff, timespec_t &t0, timespec_t &t1);
103 /// I/O handle for /proc file system.
104 ACE_HANDLE proc_handle_;
106 #elif defined (ACE_HAS_GETRUSAGE)
107 /// Subtract two timestructs and store their difference.
108 void subtract (timeval &tdiff,
109 timeval &t0,
110 timeval &t1);
112 /// Keep track of the beginning time.
113 timeval begin_time_;
115 /// Keep track of the ending time.
116 timeval end_time_;
118 /// Keep track of the last time for incremental timing.
119 timeval last_time_;
120 #endif /* ACE_HAS_PRUSAGE_T */
122 #if defined (ACE_WIN32) || (!defined (ACE_HAS_PRUSAGE_T) && !defined (ACE_HAS_GETRUSAGE))
123 /// The high resolution timer
124 ACE_High_Res_Timer timer_;
125 #endif /* ACE_WIN32 || !ACE_HAS_PRUSAGE_T && !ACE_HAS_GETRUSAGE */
128 ACE_END_VERSIONED_NAMESPACE_DECL
130 #if defined (__ACE_INLINE__)
131 # include "ace/Profile_Timer.inl"
132 #endif /* __ACE_INLINE__ */
134 #include /**/ "ace/post.h"
135 #endif /* ACE_PROFILE_TIMER_H */