summaryrefslogtreecommitdiff
path: root/ace/High_Res_Timer.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'ace/High_Res_Timer.cpp')
-rw-r--r--ace/High_Res_Timer.cpp30
1 files changed, 13 insertions, 17 deletions
diff --git a/ace/High_Res_Timer.cpp b/ace/High_Res_Timer.cpp
index f2ba4c05687..57ece6e2f05 100644
--- a/ace/High_Res_Timer.cpp
+++ b/ace/High_Res_Timer.cpp
@@ -75,12 +75,11 @@ ACE_High_Res_Timer::get_cpuinfo (void)
int supported = 0;
#endif /* __alpha__ */
- FILE *cpuinfo = ACE_OS::fopen (ACE_LIB_TEXT ("/proc/cpuinfo"),
- ACE_LIB_TEXT ("r"));
+ FILE *cpuinfo = ACE_OS::fopen ("/proc/cpuinfo", "r");
if (cpuinfo != 0)
{
- char buf[128];
+ ACE_TCHAR buf[128];
// ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\nReading /proc/cpuinfo...")));
@@ -104,7 +103,7 @@ ACE_High_Res_Timer::get_cpuinfo (void)
#else
double mhertz = 1;
double bmips = 1;
- char arg[128];
+ ACE_TCHAR arg[128];
// CPU type?
if (::sscanf (buf, "cpu : %s\n", arg) == 1)
@@ -334,17 +333,16 @@ ACE_High_Res_Timer::reset (void)
{
ACE_TRACE ("ACE_High_Res_Timer::reset");
- this->start_ = 0;
- this->end_ = 0;
- this->total_ = 0;
- this->start_incr_ = 0;
+ start_ = 0;
+ end_ = 0;
+ total_ = 0;
+ start_incr_ = 0;
}
void
ACE_High_Res_Timer::elapsed_time (ACE_Time_Value &tv) const
{
- hrtime_to_tv (tv,
- ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_));
+ hrtime_to_tv (tv, end_ - start_);
}
#if defined (ACE_HAS_POSIX_TIME)
@@ -362,14 +360,12 @@ ACE_High_Res_Timer::elapsed_time (struct timespec &elapsed_time) const
// Then it converts that to nanoseconds by dividing by the scale
// factor to convert to usec, and multiplying by 1000.) The cast
// avoids a MSVC 4.1 compiler warning about narrowing.
- ACE_hrtime_t elapsed =
- ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_);
- u_long nseconds = static_cast<u_long> (elapsed %
+ u_long nseconds = static_cast<u_long> ((this->end_ - this->start_) %
global_scale_factor () * 1000u /
global_scale_factor ());
// Get just the microseconds (dropping any left over nanoseconds).
- ACE_UINT32 useconds = (ACE_UINT32) (elapsed / global_scale_factor ());
+ ACE_UINT32 useconds = (ACE_UINT32) ((this->end_ - this->start_) / global_scale_factor ());
#if ! defined(ACE_HAS_BROKEN_TIMESPEC_MEMBERS)
elapsed_time.tv_sec = (time_t) (useconds / ACE_ONE_SECOND_IN_USECS);
@@ -397,10 +393,10 @@ ACE_High_Res_Timer::elapsed_time (ACE_hrtime_t &nanoseconds) const
// native 64-bit ints. In particular, division can be a problem.
// For more background on this, please see bugzilla #1024.
#if defined (ACE_WIN32)
- nanoseconds = ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_)
+ nanoseconds = (this->end_ - this->start_)
* (1024000000u / ACE_High_Res_Timer::global_scale_factor());
#else
- nanoseconds = ACE_High_Res_Timer::elapsed_hrtime (this->end_, this->start_)
+ nanoseconds = (this->end_ - this->start_)
* (1024000u / ACE_High_Res_Timer::global_scale_factor ());
#endif /* ACE_WIN32 */
// Caution - Borland has a problem with >>=, so resist the temptation.
@@ -517,7 +513,7 @@ ACE_High_Res_Timer::get_env_global_scale_factor (const ACE_TCHAR *env)
#if !defined (ACE_HAS_WINCE)
if (env != 0)
{
- const char *env_value = ACE_OS::getenv (ACE_TEXT_ALWAYS_CHAR (env));
+ const ACE_TCHAR *env_value = ACE_OS::getenv (env);
if (env_value != 0)
{
int value = ACE_OS::atoi (env_value);