diff options
author | Thomas White <taw@physics.org> | 2022-09-24 18:12:14 +0200 |
---|---|---|
committer | Thomas White <taw@physics.org> | 2022-10-05 15:59:47 +0200 |
commit | c1b68da99062d3d26eb49472c38b44ac5af64402 (patch) | |
tree | bc4330b3c2fe480ecd2364e572c2d31fe05e97bf | |
parent | 429e9b1e342f7487d1b109cc8232223c85322e5d (diff) |
indexamajig: Improve accuracy of speed reports
-rw-r--r-- | src/im-sandbox.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/src/im-sandbox.c b/src/im-sandbox.c index 87a05d03..8231b041 100644 --- a/src/im-sandbox.c +++ b/src/im-sandbox.c @@ -68,7 +68,7 @@ struct sandbox { int n_processed_last_stats; - time_t t_last_stats; + double t_last_stats; /* Processing timeout in seconds. After this long without responding * to a ping, the worker will be killed. After 3 times this long @@ -123,11 +123,11 @@ struct get_pattern_ctx #ifdef HAVE_CLOCK_GETTIME -static time_t get_monotonic_seconds() +static double get_monotonic_seconds() { struct timespec tp; clock_gettime(CLOCK_MONOTONIC, &tp); - return tp.tv_sec; + return tp.tv_sec + tp.tv_nsec * 1e-9; } #else @@ -135,11 +135,11 @@ static time_t get_monotonic_seconds() /* Fallback version of the above. The time according to gettimeofday() is not * monotonic, so measuring intervals based on it will screw up if there's a * timezone change (e.g. daylight savings) while the program is running. */ -static time_t get_monotonic_seconds() +static double get_monotonic_seconds() { struct timeval tp; gettimeofday(&tp, NULL); - return tp.tv_sec; + return tp.tv_sec + tp.tv_usec * 1e-6; } #endif @@ -981,8 +981,8 @@ static void try_status(struct sandbox *sb, int final) { int r; int n_proc_this; - time_t tNow; - time_t time_this; + double tNow; + double time_this; const char *finalstr; char persec[64]; |