[mlpack-svn] r11832 - mlpack/trunk/src/mlpack/core/util

fastlab-svn at coffeetalk-1.cc.gatech.edu fastlab-svn at coffeetalk-1.cc.gatech.edu
Mon Mar 12 15:23:11 EDT 2012


Author: rcurtin
Date: 2012-03-12 15:23:11 -0400 (Mon, 12 Mar 2012)
New Revision: 11832

Modified:
   mlpack/trunk/src/mlpack/core/util/timers.cpp
Log:
Fix apparently untested Windows code.

Modified: mlpack/trunk/src/mlpack/core/util/timers.cpp
===================================================================
--- mlpack/trunk/src/mlpack/core/util/timers.cpp	2012-03-12 19:22:42 UTC (rev 11831)
+++ mlpack/trunk/src/mlpack/core/util/timers.cpp	2012-03-12 19:23:11 UTC (rev 11832)
@@ -118,20 +118,6 @@
   timers[timerName] = tmp;
 }
 
-void Timers::StopTimer(const std::string& timerName)
-{
-  timeval delta, b, a = timers[timerName];
-
-#ifndef _WIN32
-  gettimeofday(&b, NULL);
-#else
-  FileTimeToTimeVal(&b);
-#endif
-  // Calculate the delta time.
-  timersub(&b, &a, &delta);
-  timers[timerName] = delta;
-}
-
 #ifdef _WIN32
 void Timers::FileTimeToTimeVal(timeval* tv)
 {
@@ -144,10 +130,34 @@
   ptime = ptime << 32;
   ptime |= ftime.dwLowDateTime;
   ptime /= 10;
-  ptime -= DELTA_EPOCH_IN_MICROSECONDS;
+  ptime -= DELTA_EPOCH_IN_MICROSECS;
 
   tv->tv_sec = (long) (ptime / 1000000UL);
   tv->tv_usec = (long) (ptime % 1000000UL);
 }
 
+inline void timersub(const timeval* tvp, const timeval* uvp, timeval * vvp) 
+{
+  vvp->tv_sec = tvp->tv_sec - uvp->tv_sec; 
+  vvp->tv_usec = tvp->tv_usec - uvp->tv_usec; 
+  if (vvp->tv_usec < 0) 
+  { 
+     --vvp->tv_sec; 
+     vvp->tv_usec += 1000000; 
+  } 
+}
 #endif // _WIN32
+
+void Timers::StopTimer(const std::string& timerName)
+{
+  timeval delta, b, a = timers[timerName];
+
+#ifndef _WIN32
+  gettimeofday(&b, NULL);
+#else
+  FileTimeToTimeVal(&b);
+#endif
+  // Calculate the delta time.
+  timersub(&b, &a, &delta);
+  timers[timerName] = delta;
+}




More information about the mlpack-svn mailing list