summaryrefslogtreecommitdiffstats
path: root/src/misc
diff options
context:
space:
mode:
authorAlan Mishchenko <alanmi@berkeley.edu>2013-06-18 11:26:37 -0700
committerAlan Mishchenko <alanmi@berkeley.edu>2013-06-18 11:26:37 -0700
commit13dd754a8c0113bebc0ad65def80d4caf5fc9b60 (patch)
treee2acff27779f1355e842ff135c7742337a481b35 /src/misc
parentb91c41659e61c2b4bd6b5a9b23862d8c093daa05 (diff)
downloadabc-13dd754a8c0113bebc0ad65def80d4caf5fc9b60.tar.gz
abc-13dd754a8c0113bebc0ad65def80d4caf5fc9b60.tar.bz2
abc-13dd754a8c0113bebc0ad65def80d4caf5fc9b60.zip
Suggested changes to counting time in Abc_Clock()
Diffstat (limited to 'src/misc')
-rw-r--r--src/misc/util/abc_global.h20
1 files changed, 10 insertions, 10 deletions
diff --git a/src/misc/util/abc_global.h b/src/misc/util/abc_global.h
index 5d6a8aeb..d9aa9701 100644
--- a/src/misc/util/abc_global.h
+++ b/src/misc/util/abc_global.h
@@ -271,18 +271,18 @@ static inline int Abc_Lit2LitL( int * pMap, int Lit ) { return Abc_LitNo
typedef ABC_INT64_T abctime;
static inline abctime Abc_Clock()
{
- static abctime PeriodNum = 0;
- static clock_t Period = ((abctime)1 << 30);
- clock_t ClockTime = clock();
- if ( ClockTime >= Period )
- {
- ClockTime -= Period;
- PeriodNum++;
- }
- return PeriodNum * Period + ClockTime;
+#if defined(LIN) || defined(LIN64)
+ struct timespec ts;
+ if ( clock_gettime(CLOCK_THREAD_CPUTIME_ID, &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
}
-
// bridge communication
#define BRIDGE_NETLIST 106
#define BRIDGE_ABS_NETLIST 107