From c1b68da99062d3d26eb49472c38b44ac5af64402 Mon Sep 17 00:00:00 2001 From: Thomas White Date: Sat, 24 Sep 2022 18:12:14 +0200 Subject: indexamajig: Improve accuracy of speed reports --- src/im-sandbox.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/im-sandbox.c') 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]; -- cgit v1.2.3