summaryrefslogtreecommitdiff
path: root/ace/High_Res_Timer.cpp
diff options
context:
space:
mode:
authorlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-21 21:41:34 +0000
committerlevine <levine@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1996-10-21 21:41:34 +0000
commita5fdebc5f6375078ec1763850a4ca23ec7fe6458 (patch)
treebcf0a25c3d45a209a6e3ac37b233a4812f29c732 /ace/High_Res_Timer.cpp
downloadATCD-a5fdebc5f6375078ec1763850a4ca23ec7fe6458.tar.gz
Initial revision
Diffstat (limited to 'ace/High_Res_Timer.cpp')
-rw-r--r--ace/High_Res_Timer.cpp74
1 files changed, 74 insertions, 0 deletions
diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp
new file mode 100644
index 00000000000..aad19e26799
--- /dev/null
+++ b/ace/High_Res_Timer.cpp
@@ -0,0 +1,74 @@
+// High_Res_Timer.cpp
+// $Id$
+
+#define ACE_BUILD_DLL
+#include "ace/Log_Msg.h"
+#include "ace/High_Res_Timer.h"
+
+#if !defined (__ACE_INLINE__)
+#include "ace/High_Res_Timer.i"
+#endif /* __ACE_INLINE__ */
+
+#if defined (ACE_HAS_HI_RES_TIMER)
+
+ACE_ALLOC_HOOK_DEFINE(ACE_High_Res_Timer)
+
+void
+ACE_High_Res_Timer::dump (void) const
+{
+ ACE_TRACE ("ACE_High_Res_Timer::dump");
+
+ ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
+ ACE_DEBUG ((LM_DEBUG, "\n"));
+ ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
+}
+
+void
+ACE_High_Res_Timer::reset (void)
+{
+ ACE_TRACE ("ACE_High_Res_Timer::reset");
+ (void) ACE_OS::memset (&this->start_, 0, sizeof this->start_);
+ (void) ACE_OS::memset (&this->end_, 0, sizeof this->end_);
+ (void) ACE_OS::memset (&this->total_, 0, sizeof this->total_);
+ (void) ACE_OS::memset (&this->temp_, 0, sizeof this->temp_);
+}
+
+ACE_High_Res_Timer::ACE_High_Res_Timer (void)
+{
+ ACE_TRACE ("ACE_High_Res_Timer::ACE_High_Res_Timer");
+ this->reset ();
+}
+
+void
+ACE_High_Res_Timer::print_ave (char *str, int count, ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_High_Res_Timer::print_ave");
+#if defined (ACE_HAS_LONGLONG_T)
+ hrtime_t total = this->end_ - this->start_;
+ hrtime_t avg_nsecs = total / count;
+ hrtime_t total_secs = total / (1000 * 1000 * 1000);
+ hrtime_t extra_nsecs = total - (total_secs * (1000 * 1000 * 1000));
+ char buf[100];
+
+ ACE_OS::sprintf (buf, "%s count = %d, total (secs %lld, usecs %lld), avg usecs = %lld\n",
+ str, count, total_secs, extra_nsecs / 1000, avg_nsecs / 1000);
+ ACE_OS::write (handle, buf, strlen (buf));
+#endif /* ACE_HAS_LONGLONG_T */
+}
+
+void
+ACE_High_Res_Timer::print_total (char *str, int count, ACE_HANDLE handle)
+{
+ ACE_TRACE ("ACE_High_Res_Timer::print_total");
+#if defined (ACE_HAS_LONGLONG_T)
+ hrtime_t avg_nsecs = this->total_ / count;
+ hrtime_t total_secs = this->total_ / (1000 * 1000 * 1000);
+ hrtime_t extra_nsecs = this->total_ - (total_secs * (1000 * 1000 * 1000));
+ char buf[100];
+
+ ACE_OS::sprintf (buf, "%s count = %d, total (secs %lld, usecs %lld), avg usecs = %lld\n",
+ str, count, total_secs, extra_nsecs / 1000, avg_nsecs / 1000);
+ ACE_OS::write (handle, buf, strlen (buf));
+#endif /* ACE_HAS_LONGLONG_T */
+}
+#endif /* ACE_HAS_HI_RES_TIMER */