guix-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

03/04: Make call-with-time-logging handle multiple return values


From: Christopher Baines
Subject: 03/04: Make call-with-time-logging handle multiple return values
Date: Wed, 12 Aug 2020 03:55:07 -0400 (EDT)

cbaines pushed a commit to branch master
in repository data-service.

commit bef826cf2ef17d5d7d9a6f4b339b5b40c82075d0
Author: Danjela Lura <danielaluraa@gmail.com>
AuthorDate: Fri Aug 7 18:52:30 2020 +0200

    Make call-with-time-logging handle multiple return values
    
    Signed-off-by: Christopher Baines <mail@cbaines.net>
---
 guix-data-service/utils.scm | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/guix-data-service/utils.scm b/guix-data-service/utils.scm
index 1eb3e4f..738f839 100644
--- a/guix-data-service/utils.scm
+++ b/guix-data-service/utils.scm
@@ -16,18 +16,21 @@
 ;;; <http://www.gnu.org/licenses/>.
 
 (define-module (guix-data-service utils)
+  #:use-module (srfi srfi-11)
   #:export (call-with-time-logging
             with-time-logging
             prevent-inlining-for-tests))
 
 (define (call-with-time-logging action thunk)
   (simple-format #t "debug: Starting ~A\n" action)
-  (let* ((start-time (current-time))
-         (result (thunk))
-         (time-taken (- (current-time) start-time)))
-    (simple-format #t "debug: Finished ~A, took ~A seconds\n"
-                   action time-taken)
-    result))
+  (let-values
+      ((result
+         (thunk)))
+      (let* ((start-time (current-time))
+             (time-taken (- (current-time) start-time)))
+        (simple-format #t "debug: Finished ~A, took ~A seconds\n"
+                       action time-taken)
+        (apply values result))))
 
 (define-syntax-rule (with-time-logging action exp ...)
   "Log under NAME the time taken to evaluate EXP."



reply via email to

[Prev in Thread] Current Thread [Next in Thread]