Make call-with-time-logging handle multiple return values
Signed-off-by: Christopher Baines <mail@cbaines.net>
This commit is contained in:
parent
5b3e5d9441
commit
bef826cf2e
1 changed files with 9 additions and 6 deletions
|
|
@ -16,18 +16,21 @@
|
||||||
;;; <http://www.gnu.org/licenses/>.
|
;;; <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
(define-module (guix-data-service utils)
|
(define-module (guix-data-service utils)
|
||||||
|
#:use-module (srfi srfi-11)
|
||||||
#:export (call-with-time-logging
|
#:export (call-with-time-logging
|
||||||
with-time-logging
|
with-time-logging
|
||||||
prevent-inlining-for-tests))
|
prevent-inlining-for-tests))
|
||||||
|
|
||||||
(define (call-with-time-logging action thunk)
|
(define (call-with-time-logging action thunk)
|
||||||
(simple-format #t "debug: Starting ~A\n" action)
|
(simple-format #t "debug: Starting ~A\n" action)
|
||||||
|
(let-values
|
||||||
|
((result
|
||||||
|
(thunk)))
|
||||||
(let* ((start-time (current-time))
|
(let* ((start-time (current-time))
|
||||||
(result (thunk))
|
|
||||||
(time-taken (- (current-time) start-time)))
|
(time-taken (- (current-time) start-time)))
|
||||||
(simple-format #t "debug: Finished ~A, took ~A seconds\n"
|
(simple-format #t "debug: Finished ~A, took ~A seconds\n"
|
||||||
action time-taken)
|
action time-taken)
|
||||||
result))
|
(apply values result))))
|
||||||
|
|
||||||
(define-syntax-rule (with-time-logging action exp ...)
|
(define-syntax-rule (with-time-logging action exp ...)
|
||||||
"Log under NAME the time taken to evaluate EXP."
|
"Log under NAME the time taken to evaluate EXP."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue