From 52172d234015776bcc595c731477b98fa2949e50 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Sat, 14 Sep 2019 10:55:53 -0700 Subject: [PATCH] Fix gc-elapsed rounding bug MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit * src/alloc.c (garbage_collect): Don’t accumulate rounding errors when computing gc-elapsed. --- src/alloc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/alloc.c b/src/alloc.c index 497f600551e..9fbd0d05739 100644 --- a/src/alloc.c +++ b/src/alloc.c @@ -6021,9 +6021,10 @@ garbage_collect (void) /* Accumulate statistics. */ if (FLOATP (Vgc_elapsed)) { - struct timespec since_start = timespec_sub (current_timespec (), start); - Vgc_elapsed = make_float (XFLOAT_DATA (Vgc_elapsed) - + timespectod (since_start)); + static struct timespec gc_elapsed; + gc_elapsed = timespec_add (gc_elapsed, + timespec_sub (current_timespec (), start)); + Vgc_elapsed = make_float (timespectod (gc_elapsed)); } gcs_done++; -- 2.39.5