From c51c081d9011696276e25c1b2499ade60d3178ad Mon Sep 17 00:00:00 2001 From: Alan Mishchenko Date: Tue, 25 Jul 2023 12:54:22 -0700 Subject: [PATCH] Changing default time counting from thread time to wall time. --- src/misc/util/abc_global.h | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h index 2217bb87e..c7b6f160b 100644 --- a/src/misc/util/abc_global.h +++ b/src/misc/util/abc_global.h @@ -325,8 +325,8 @@ static inline int Abc_Var2Lit4( int Var, int Att ) { assert(!(Att >> static inline int Abc_Lit2Var4( int Lit ) { assert(Lit >= 0); return Lit >> 4; } static inline int Abc_Lit2Att4( int Lit ) { assert(Lit >= 0); return Lit & 15; } -// time counting typedef ABC_INT64_T abctime; +// counting wall time static inline abctime Abc_Clock() { #if defined(__APPLE__) && defined(__MACH__) @@ -334,6 +334,25 @@ static inline abctime Abc_Clock() #else #define APPLE_MACH 0 #endif +#if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) + struct timespec ts; + if ( clock_gettime(CLOCK_MONOTONIC, &ts) < 0 ) + return (abctime)-1; + abctime res = ((abctime) ts.tv_sec) * CLOCKS_PER_SEC; + res += (((abctime) ts.tv_nsec) * CLOCKS_PER_SEC) / 1000000000; + return res; +#else + return (abctime) clock(); +#endif +} +// counting thread time +static inline abctime Abc_ThreadClock() +{ +#if defined(__APPLE__) && defined(__MACH__) + #define APPLE_MACH (__APPLE__ & __MACH__) +#else + #define APPLE_MACH 0 +#endif #if (defined(LIN) || defined(LIN64)) && !APPLE_MACH && !defined(__MINGW32__) struct timespec ts; if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &ts) < 0 ) @@ -346,7 +365,6 @@ static inline abctime Abc_Clock() #endif } - // misc printing procedures enum Abc_VerbLevel {