From 88e7e0a5e4061643209caa6a354df29f97a31b30 Mon Sep 17 00:00:00 2001 From: Matthew Flatt Date: Sat, 5 Oct 2019 20:26:10 -0600 Subject: [PATCH] cs: fix `time-apply` process timing The `time-apply` function was measuring thread time instead of proecss time. While thread time would be more useful in many cases, it's meant to report process time. --- racket/src/cs/rumble/time.ss | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/racket/src/cs/rumble/time.ss b/racket/src/cs/rumble/time.ss index 98af6f3d85..5197710880 100644 --- a/racket/src/cs/rumble/time.ss +++ b/racket/src/cs/rumble/time.ss @@ -78,21 +78,19 @@ (/ (time-nanosecond t) 1000000.))) (define (time-apply f extra) - (let ([stats (statistics)]) + (let ([pre-cpu (current-time 'time-process)] + [pre-real (current-time 'time-monotonic)] + [pre-gc (#%$gc-cpu-time)]) (call-with-values (lambda () (apply f extra)) (lambda args - (let ([new-stats (statistics)]) + (let ([post-cpu (current-time 'time-process)] + [post-real (current-time 'time-monotonic)] + [post-gc (#%$gc-cpu-time)]) (values args - (inexact->exact (floor (time->ms - (time-difference (sstats-cpu new-stats) - (sstats-cpu stats))))) - (inexact->exact (floor (time->ms - (time-difference (sstats-real new-stats) - (sstats-real stats))))) - (inexact->exact (floor (time->ms - (time-difference (sstats-gc-cpu new-stats) - (sstats-gc-cpu stats))))))))))) + (inexact->exact (floor (time->ms (time-difference post-cpu pre-cpu)))) + (inexact->exact (floor (time->ms (time-difference post-real pre-real)))) + (inexact->exact (floor (time->ms (time-difference post-gc pre-gc)))))))))) (define (current-gc-milliseconds) (inexact->exact (floor (time->ms (#%$gc-cpu-time)))))