From 3e63d6ca5d727d09d7dd49782f5b1da067bb72db Mon Sep 17 00:00:00 2001 From: curt Date: Mon, 2 Nov 1998 18:28:31 +0000 Subject: [PATCH] Additional win32 support. --- Misc/stopwatch.hxx | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/Misc/stopwatch.hxx b/Misc/stopwatch.hxx index 400c08fc..e4034ac8 100644 --- a/Misc/stopwatch.hxx +++ b/Misc/stopwatch.hxx @@ -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. * @@ -58,10 +61,16 @@ # define HAVE_GETRUSAGE #endif -#ifdef HAVE_GETRUSAGE - #include +#if defined( WIN32 ) && defined( HAVE_GETRUSAGE ) +# undef HAVE_GETRUSAGE +#endif // WIN32 + +#if defined( HAVE_GETRUSAGE ) +# include +#elif defined( WIN32 ) +# include #else - #include +# include #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