]> git.mxchange.org Git - simgear.git/blobdiff - Misc/stopwatch.hxx
Added the Serial subdirectory
[simgear.git] / Misc / stopwatch.hxx
index 400c08fc1d58e63f1309d925b410cc0ab68bd37d..e4034ac88f8a4c12233bc476ea4b1923f55fe40a 100644 (file)
@@ -25,6 +25,9 @@
  *
  ***************************************************************************
  * $Log$
+ * Revision 1.2  1998/11/02 18:28:31  curt
+ * Additional win32 support.
+ *
  * Revision 1.1  1998/09/01 19:06:30  curt
  * Initial revision.
  *
 #  define HAVE_GETRUSAGE
 #endif
 
-#ifdef HAVE_GETRUSAGE
- #include <sys/resource.h>
+#if defined( WIN32 ) && defined( HAVE_GETRUSAGE )
+#  undef HAVE_GETRUSAGE
+#endif // WIN32
+
+#if defined( HAVE_GETRUSAGE )
+#  include <sys/resource.h>
+#elif defined( WIN32 )
+#  include <windows.h>
 #else
- #include <time.h>
+#  include <time.h>
 #endif
 
 class StopWatch {
@@ -97,13 +106,15 @@ private:
 
     double systemTime()
     {
-#ifdef HAVE_GETRUSAGE
+#if defined( HAVE_GETRUSAGE )
         getrusage(RUSAGE_SELF, &resourceUsage_);
         double seconds = resourceUsage_.ru_utime.tv_sec 
             + resourceUsage_.ru_stime.tv_sec;
         double micros  = resourceUsage_.ru_utime.tv_usec 
             + resourceUsage_.ru_stime.tv_usec;
         return seconds + micros/1.0e6;
+#elif defined( WIN32 )
+       return double(GetTickCount()) * double(1e-3);
 #else
         return clock() / (double) CLOCKS_PER_SEC;
 #endif
@@ -111,7 +122,7 @@ private:
 
 //     enum { uninitialized, running, stopped } state_;
 
-#ifdef HAVE_GETRUSAGE
+#if defined( HAVE_GETRUSAGE )
     struct rusage resourceUsage_;
 #endif