diff options
author | Alan Mishchenko <alanmi@berkeley.edu> | 2008-03-05 08:01:00 -0800 |
---|---|---|
committer | Alan Mishchenko <alanmi@berkeley.edu> | 2008-03-05 08:01:00 -0800 |
commit | 8bd19a27bf2f50b7502d01bbbbe71714c154cd2f (patch) | |
tree | b36f9f438158f8d95e932728ab4af809a63838d1 /src/misc | |
parent | 320c429bc46728c1faddfc561c166810aa134a04 (diff) | |
download | abc-8bd19a27bf2f50b7502d01bbbbe71714c154cd2f.tar.gz abc-8bd19a27bf2f50b7502d01bbbbe71714c154cd2f.tar.bz2 abc-8bd19a27bf2f50b7502d01bbbbe71714c154cd2f.zip |
Version abc80305
Diffstat (limited to 'src/misc')
-rw-r--r-- | src/misc/extra/extraUtilUtil.c | 44 |
1 files changed, 28 insertions, 16 deletions
diff --git a/src/misc/extra/extraUtilUtil.c b/src/misc/extra/extraUtilUtil.c index c685f7bc..e2c407cd 100644 --- a/src/misc/extra/extraUtilUtil.c +++ b/src/misc/extra/extraUtilUtil.c @@ -49,22 +49,6 @@ static char *pScanStr; /**Function************************************************************* - Synopsis [util_cpu_time()] - - Description [] - - SideEffects [] - - SeeAlso [] - -***********************************************************************/ -long Extra_CpuTime() -{ - return clock(); -} - -/**Function************************************************************* - Synopsis [getSoftDataLimit()] Description [] @@ -349,6 +333,34 @@ void Extra_UtilMMout_Of_Memory( long size ) void (*Extra_UtilMMoutOfMemory)() = Extra_UtilMMout_Of_Memory; +/**Function************************************************************* + + Synopsis [util_cpu_time()] + + Description [] + + SideEffects [] + + SeeAlso [] + +***********************************************************************/ +#if defined(NT) || defined(NT64) || defined(WIN32) +long Extra_CpuTime() +{ + return clock(); +} +#else +#include <sys/time.h> +#include <sys/resource.h> +#include <unistd.h> +long Extra_CpuTime() +{ + struct rusage ru; + getrusage(RUSAGE_SELF, &ru); + return (long)(CLOCKS_PER_SEC * ((double)ru.ru_utime.tv_sec + (double)ru.ru_utime.tv_usec / 1000000)); +} +#endif + //////////////////////////////////////////////////////////////////////// /// END OF FILE /// //////////////////////////////////////////////////////////////////////// |