This is the mail archive of the
guile@sources.redhat.com
mailing list for the Guile project.
Re: time macro
Marius Vollmer <mvo@zagadka.ping.de> writes:
> > (define-macro (time form)
> > `(let ((tms-start (times))
>
> Nit: you might want to use `let*' for clarity. `let' does not
> guarantee sequential execution of the initialization forms.
Thanks. Also, I could have used internal-time-units-per-second,
so it can be defined as follows:
(define-macro (time form)
`(let* ((gc-start (gc-run-time))
(tms-start (times))
(result ,form)
(tms-end (times))
(gc-end (gc-run-time))
(get (lambda (proc start end)
(/ (- (proc end) (proc start))
internal-time-units-per-second))))
(display "clock utime stime cutime cstime gc\n")
(format #t "~5a ~5a ~5a ~6a ~6a ~a~%"
(get tms:clock tms-start tms-end)
(get tms:utime tms-start tms-end)
(get tms:stime tms-start tms-end)
(get tms:cutime tms-start tms-end)
(get tms:cstime tms-start tms-end)
(get id gc-start gc-end))
result))