[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: timevar: 3/3: use clock_gettime to get wall clock time
From: |
Akim Demaille |
Subject: |
Re: timevar: 3/3: use clock_gettime to get wall clock time |
Date: |
Fri, 12 Oct 2018 06:57:02 +0200 |
On macOS, I get an unexpected result for wall clock.
Execution times (seconds)
CPU user CPU system wall clock
reader 0,017 ( 4%) 0,002 (13%) 0,000000 ( 0%)
LALR(1) 0,002 ( 0%) 0,000 ( 1%) 0,031250 ( 6%)
outputting report 0,027 ( 5%) 0,002 (13%) 0,031250 ( 6%)
parser action tables 0,018 ( 4%) 0,001 ( 7%) 0,000000 ( 0%)
outputting parser 0,012 ( 2%) 0,001 (10%) 0,062500 (12%)
running m4 0,407 (84%) 0,008 (54%) 0,375000 (75%)
total time 0,488 0,014 0,500000
commit 48624ae07a9fa3c9d79a92b39e7ca31b4fb0c263
Author: Akim Demaille <address@hidden>
Date: Fri Oct 12 06:46:09 2018 +0200
timevar: use clock_gettime to get wall clock time
* modules/timevar (Depends-on): We need time.h.
We no longer use times().
* lib/timevar.c (set_to_current_time): Use clock_gettime.
diff --git a/ChangeLog b/ChangeLog
index 369848b12..bb550a54b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2018-10-12 Akim Demaille <address@hidden>
+
+ timevar: use clock_gettime to get wall clock time
+ * modules/timevar (Depends-on): We need time.h.
+ We no longer use times().
+ * lib/timevar.c (set_to_current_time): Use clock_gettime.
+
2018-10-12 Akim Demaille <address@hidden>
timevar: improve the output format
diff --git a/lib/timevar.c b/lib/timevar.c
index 8b574e277..13fa6bf75 100644
--- a/lib/timevar.c
+++ b/lib/timevar.c
@@ -29,6 +29,7 @@
#include <sys/resource.h>
#include <sys/time.h>
#include <sys/times.h>
+#include <time.h>
#include "gettext.h"
#define _(msgid) gettext (msgid)
@@ -108,6 +109,10 @@ set_to_current_time (struct timevar_time_def *now)
getrusage (RUSAGE_CHILDREN, &rusage);
now->user += rusage.ru_utime.tv_sec + rusage.ru_utime.tv_usec * 1e-6;
now->sys += rusage.ru_stime.tv_sec + rusage.ru_stime.tv_usec * 1e-6;
+
+ struct timespec timespec;
+ clock_gettime(CLOCK_MONOTONIC, ×pec);
+ now->wall = timespec.tv_sec + timespec.tv_nsec * 1e-9;
}
/* Return the current time. */
diff --git a/modules/timevar b/modules/timevar
index 8be1b8318..d0712720b 100644
--- a/modules/timevar
+++ b/modules/timevar
@@ -12,7 +12,7 @@ gettext-h
stdlib
sys_time
sys_times
-times
+time
xalloc
Makefile.am:
- Re: timevar: further work, (continued)
- Re: timevar: further work, Akim Demaille, 2018/10/11
- Re: timevar: further work, Bruno Haible, 2018/10/11
- Re: timevar: further work, Akim Demaille, 2018/10/11
- Re: timevar: further work, Akim Demaille, 2018/10/11
- Re: timevar: 1/3: expect that getrusage is available, Akim Demaille, 2018/10/12
- Re: timevar: 1/3: expect that getrusage is available, Bruno Haible, 2018/10/12
- Re: timevar: 1/3: expect that getrusage is available, Akim Demaille, 2018/10/13
- Re: timevar: 1/3: expect that getrusage is available, Bruno Haible, 2018/10/13
- Re: timevar: 2/3: improve the output format, Akim Demaille, 2018/10/12
- Re: timevar: 2/3: improve the output format, Bruno Haible, 2018/10/12
- Re: timevar: 3/3: use clock_gettime to get wall clock time,
Akim Demaille <=
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Bruno Haible, 2018/10/12
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Akim Demaille, 2018/10/13
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Bruno Haible, 2018/10/13
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Akim Demaille, 2018/10/13
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Bruno Haible, 2018/10/13
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Akim Demaille, 2018/10/13
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Bruno Haible, 2018/10/13
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Akim Demaille, 2018/10/14
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Bruno Haible, 2018/10/14
- Re: timevar: 3/3: use clock_gettime to get wall clock time, Akim Demaille, 2018/10/14