Changing default time counting from thread time to wall time.

This commit is contained in:
Alan Mishchenko 2023-07-25 12:54:22 -07:00
parent a3942996e7
commit c51c081d90
1 changed files with 20 additions and 2 deletions

View File

@ -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
{