GitHub Actions: Try MSVC builds with /std:c++17 and 20
[ACE_TAO.git] / ACE / ace / Profile_Timer.inl
blob3b52d41954fd583c8890cc341d6a49bf62d333c8
1 // -*- C++ -*-
2 #include "ace/OS_NS_sys_time.h"
3 #include "ace/OS_NS_sys_resource.h"
4 #include "ace/Global_Macros.h"
6 #if (defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE)) && !defined (ACE_WIN32)
8 #  if defined (ACE_HAS_PRUSAGE_T)
9 #    include "ace/OS_NS_stropts.h"
11 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
13 ACE_INLINE int
14 ACE_Profile_Timer::start (void)
16   ACE_TRACE ("ACE_Profile_Timer::start");
17   return ACE_OS::ioctl (this->proc_handle_,
18                         PIOCUSAGE,
19                         &this->begin_usage_);
22 ACE_INLINE int
23 ACE_Profile_Timer::stop (void)
25   ACE_TRACE ("ACE_Profile_Timer::stop");
26   this->last_usage_ = this->end_usage_;
27   return ACE_OS::ioctl (this->proc_handle_,
28                     PIOCUSAGE,
29                     &this->end_usage_);
32 ACE_END_VERSIONED_NAMESPACE_DECL
34 #  elif defined (ACE_HAS_GETRUSAGE)
36 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
38 ACE_INLINE int
39 ACE_Profile_Timer::start (void)
41   ACE_TRACE ("ACE_Profile_Timer::start");
42   this->begin_time_ = ACE_OS::gettimeofday ();
43   ACE_OS::getrusage (RUSAGE_SELF,
44                      &this->begin_usage_);
45   return 0;
48 ACE_INLINE int
49 ACE_Profile_Timer::stop (void)
51   ACE_TRACE ("ACE_Profile_Timer::stop");
52   this->last_time_ = this->end_time_;
53   this->end_time_ = ACE_OS::gettimeofday ();
54   this->last_usage_ = this->end_usage_;
55   ACE_OS::getrusage (RUSAGE_SELF,
56                      &this->end_usage_);
57   return 0;
60 ACE_END_VERSIONED_NAMESPACE_DECL
62 #  endif /* ACE_HAS_PRUSAGE_T */
64 #elif defined (ACE_WIN32)
66 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
68 ACE_INLINE
69 ACE_Profile_Timer::~ACE_Profile_Timer (void)
73 ACE_INLINE int
74 ACE_Profile_Timer::start (void)
76   ACE_TRACE ("ACE_Profile_Timer::start");
77 #  if defined (ACE_HAS_GETRUSAGE)
78   ACE_OS::getrusage (RUSAGE_SELF,
79                      &this->begin_usage_);
80 #  endif /* ACE_HAS_GETRUSAGE */
81   this->timer_.start ();
82   return 0;
85 ACE_INLINE int
86 ACE_Profile_Timer::stop (void)
88   ACE_TRACE ("ACE_Profile_Timer::stop");
89   this->timer_.stop ();
90 #  if defined (ACE_HAS_GETRUSAGE)
91   this->last_usage_ = this->end_usage_;
92   ACE_OS::getrusage (RUSAGE_SELF, &this->end_usage_);
93 #  endif /* ACE_HAS_GETRUSAGE */
94   return 0;
97 ACE_END_VERSIONED_NAMESPACE_DECL
99 #else
101 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
103 ACE_INLINE int
104 ACE_Profile_Timer::start (void)
106   ACE_TRACE ("ACE_Profile_Timer::start");
107   this->timer_.start ();
108   return 0;
111 ACE_INLINE int
112 ACE_Profile_Timer::stop (void)
114   ACE_TRACE ("ACE_Profile_Timer::stop");
115   this->timer_.stop ();
116   return 0;
119 ACE_INLINE
120 ACE_Profile_Timer::~ACE_Profile_Timer (void)
124 ACE_END_VERSIONED_NAMESPACE_DECL
126 #endif /* defined (ACE_HAS_PRUSAGE_T) || defined (ACE_HAS_GETRUSAGE) */