3 // $Id: Profile_Timer.inl 80826 2008-03-04 14:51:23Z wotte $
5 #include "ace/OS_NS_sys_time.h"
6 #include "ace/OS_NS_sys_resource.h"
7 #include "ace/Global_Macros.h"
9 #if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32)
11 # if defined (ACE_HAS_PRUSAGE_T)
12 # include "ace/OS_NS_stropts.h"
14 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
17 ACE_Profile_Timer::start (void)
19 ACE_TRACE ("ACE_Profile_Timer::start");
20 return ACE_OS::ioctl (this->proc_handle_,
26 ACE_Profile_Timer::stop (void)
28 ACE_TRACE ("ACE_Profile_Timer::stop");
29 this->last_usage_ = this->end_usage_;
30 return ACE_OS::ioctl (this->proc_handle_,
35 ACE_END_VERSIONED_NAMESPACE_DECL
37 # elif defined (ACE_HAS_GETRUSAGE)
39 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
42 ACE_Profile_Timer::start (void)
44 ACE_TRACE ("ACE_Profile_Timer::start");
45 this->begin_time_ = ACE_OS::gettimeofday ();
46 ACE_OS::getrusage (RUSAGE_SELF,
52 ACE_Profile_Timer::stop (void)
54 ACE_TRACE ("ACE_Profile_Timer::stop");
55 this->last_time_ = this->end_time_;
56 this->end_time_ = ACE_OS::gettimeofday ();
57 this->last_usage_ = this->end_usage_;
58 ACE_OS::getrusage (RUSAGE_SELF,
63 ACE_END_VERSIONED_NAMESPACE_DECL
65 # endif /* ACE_HAS_PRUSAGE_T */
67 #elif defined (ACE_WIN32)
69 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
72 ACE_Profile_Timer::~ACE_Profile_Timer (void)
77 ACE_Profile_Timer::start (void)
79 ACE_TRACE ("ACE_Profile_Timer::start");
80 # if defined (ACE_HAS_GETRUSAGE)
81 ACE_OS::getrusage (RUSAGE_SELF,
83 # endif /* ACE_HAS_GETRUSAGE */
84 this->timer_.start ();
89 ACE_Profile_Timer::stop (void)
91 ACE_TRACE ("ACE_Profile_Timer::stop");
93 # if defined (ACE_HAS_GETRUSAGE)
94 this->last_usage_ = this->end_usage_;
95 ACE_OS::getrusage (RUSAGE_SELF, &this->end_usage_);
96 # endif /* ACE_HAS_GETRUSAGE */
100 ACE_END_VERSIONED_NAMESPACE_DECL
104 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
107 ACE_Profile_Timer::start (void)
109 ACE_TRACE ("ACE_Profile_Timer::start");
110 this->timer_.start ();
115 ACE_Profile_Timer::stop (void)
117 ACE_TRACE ("ACE_Profile_Timer::stop");
118 this->timer_.stop ();
123 ACE_Profile_Timer::~ACE_Profile_Timer (void)
127 ACE_END_VERSIONED_NAMESPACE_DECL
129 #endif /* defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE) */