1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

time: Support expressions that return any number of values.

* module/ice-9/time.scm (time-proc): Call PROC with 'call-with-values';
return all its values.
This commit is contained in:
Ludovic Courtès 2018-09-23 16:27:32 +02:00 committed by Andy Wingo
parent 53c3d27bfc
commit 24f45332b0

View file

@ -35,7 +35,7 @@
(define (time-proc proc)
(let* ((gc-start (gc-run-time))
(tms-start (times))
(result (proc))
(results (call-with-values proc list))
(tms-end (times))
(gc-end (gc-run-time)))
;; FIXME: We would probably like format ~f to accept rationals, but
@ -50,7 +50,7 @@
(get tms:cutime tms-start tms-end)
(get tms:cstime tms-start tms-end)
(get identity gc-start gc-end))
result))
(apply values results)))
(define-syntax-rule (time exp)
(time-proc (lambda () exp)))