mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-11 22:31:12 +02:00
* time.scm (time): Reimplemented as a procedure call.
(Thanks to Marius Vollmer)
This commit is contained in:
parent
c40eb5944b
commit
3b9e23a7b6
2 changed files with 19 additions and 11 deletions
|
@ -1,3 +1,8 @@
|
|||
2001-03-20 Keisuke Nishida <kxn30@po.cwru.edu>
|
||||
|
||||
* time.scm (time): Reimplemented as a procedure call.
|
||||
(Thanks to Marius Vollmer)
|
||||
|
||||
2001-03-20 Keisuke Nishida <kxn30@po.cwru.edu>
|
||||
|
||||
* safe-r5rs.scm (list): Export.
|
||||
|
|
|
@ -21,20 +21,23 @@
|
|||
:use-module (ice-9 format)
|
||||
:export (time))
|
||||
|
||||
(define-macro (time form)
|
||||
(define (time-proc proc)
|
||||
(let* ((gc-start (gc-run-time))
|
||||
(tms-start (times))
|
||||
(result (eval form (interaction-environment)))
|
||||
(tms-end (times))
|
||||
(gc-end (gc-run-time)))
|
||||
(tms-start (times))
|
||||
(result (proc))
|
||||
(tms-end (times))
|
||||
(gc-end (gc-run-time)))
|
||||
(define (get proc start end)
|
||||
(/ (- (proc end) (proc start)) internal-time-units-per-second))
|
||||
(display "clock utime stime cutime cstime gctime\n")
|
||||
(format #t "~5,2F ~5,2F ~5,2F ~6,2F ~6,2F ~6,2F\n"
|
||||
(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))
|
||||
(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))
|
||||
|
||||
(define-macro (time exp)
|
||||
`(,time-proc (lambda () ,exp)))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue