summaryrefslogtreecommitdiff
path: root/tune/time.c
diff options
context:
space:
mode:
authorKevin Ryde <user42@zip.com.au>2002-02-22 23:59:38 +0100
committerKevin Ryde <user42@zip.com.au>2002-02-22 23:59:38 +0100
commitb76a977fa6d199f963fe355243c05ba9e353e86f (patch)
tree4bade06787f606ffd5b05bb387ee9da1a9f3c92e /tune/time.c
parente8b8fc5c33f3ade564dcc1f84e1cc0bc55321a0c (diff)
downloadgmp-b76a977fa6d199f963fe355243c05ba9e353e86f.tar.gz
More of:
* tune/time.c, configure.in (clock_gettime): New measuring method.
Diffstat (limited to 'tune/time.c')
-rw-r--r--tune/time.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/tune/time.c b/tune/time.c
index 5f04067a8..d42ef87ef 100644
--- a/tune/time.c
+++ b/tune/time.c
@@ -218,6 +218,13 @@ static const int have_cgt = 0;
#define clock_gettime(id,ts) abort()
#define struct_timespec struct timespec_dummy
#endif
+#ifdef CLOCK_PROCESS_CPUTIME_ID
+# define CGT_ID CLOCK_PROCESS_CPUTIME_ID
+#else
+# ifdef CLOCK_VIRTUAL
+# define CGT_ID CLOCK_VIRTUAL
+# endif
+#endif
#if HAVE_GETRUSAGE
static const int have_grus = 1;
@@ -487,9 +494,8 @@ cgt_works_p (void)
if (result != -1)
return result;
-
/* trial run to see if it works */
- if (clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &unit) != 0)
+ if (clock_gettime (CGT_ID, &unit) != 0)
{
if (speed_option_verbose)
printf ("clock_gettime doesn't work\n");
@@ -498,7 +504,7 @@ cgt_works_p (void)
}
/* get the resolution */
- if (clock_getres (CLOCK_PROCESS_CPUTIME_ID, &unit) != 0)
+ if (clock_getres (CGT_ID, &unit) != 0)
{
if (speed_option_verbose)
printf ("clock_gettime doesn't work\n");
@@ -785,7 +791,7 @@ speed_starttime (void)
}
if (have_cgt && use_cgt)
- clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &start_cgt);
+ clock_gettime (CGT_ID, &start_cgt);
if (have_rrt && use_rrt)
read_real_time (&start_rrt, sizeof(start_rrt));
@@ -919,7 +925,7 @@ speed_endtime (void)
if (have_cycles && use_cycles) speed_cyclecounter (end_cycles);
if (have_stck && use_stck) STCK (end_stck);
if (have_rrt && use_rrt) read_real_time (&end_rrt, sizeof(end_rrt));
- if (have_cgt && use_cgt) clock_gettime (CLOCK_PROCESS_CPUTIME_ID, &end_cgt);
+ if (have_cgt && use_cgt) clock_gettime (CGT_ID, &end_cgt);
if (have_gtod && use_gtod) gettimeofday (&end_gtod, NULL);
if (have_grus && use_grus) getrusage (0, &end_grus);
if (have_times && use_times) times (&end_times);