*
***************************************************************************
* $Log$
+ * Revision 1.3 1998/11/20 01:01:03 curt
+ * FreeBSD support.
+ *
+ * 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 )
+# if defined( __FreeBSD__ )
+# include <sys/types.h>
+# endif
+# include <sys/time.h>
+# include <sys/resource.h>
+# include <unistd.h>
+#elif defined( WIN32 )
+# include <windows.h>
#else
- #include <time.h>
+# include <time.h>
#endif
class StopWatch {
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
// enum { uninitialized, running, stopped } state_;
-#ifdef HAVE_GETRUSAGE
+#if defined( HAVE_GETRUSAGE )
struct rusage resourceUsage_;
#endif