mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 09:40:25 +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>
|
2001-03-20 Keisuke Nishida <kxn30@po.cwru.edu>
|
||||||
|
|
||||||
* safe-r5rs.scm (list): Export.
|
* safe-r5rs.scm (list): Export.
|
||||||
|
|
|
@ -21,20 +21,23 @@
|
||||||
:use-module (ice-9 format)
|
:use-module (ice-9 format)
|
||||||
:export (time))
|
:export (time))
|
||||||
|
|
||||||
(define-macro (time form)
|
(define (time-proc proc)
|
||||||
(let* ((gc-start (gc-run-time))
|
(let* ((gc-start (gc-run-time))
|
||||||
(tms-start (times))
|
(tms-start (times))
|
||||||
(result (eval form (interaction-environment)))
|
(result (proc))
|
||||||
(tms-end (times))
|
(tms-end (times))
|
||||||
(gc-end (gc-run-time)))
|
(gc-end (gc-run-time)))
|
||||||
(define (get proc start end)
|
(define (get proc start end)
|
||||||
(/ (- (proc end) (proc start)) internal-time-units-per-second))
|
(/ (- (proc end) (proc start)) internal-time-units-per-second))
|
||||||
(display "clock utime stime cutime cstime gctime\n")
|
(display "clock utime stime cutime cstime gctime\n")
|
||||||
(format #t "~5,2F ~5,2F ~5,2F ~6,2F ~6,2F ~6,2F\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:clock tms-start tms-end)
|
||||||
(get tms:utime tms-start tms-end)
|
(get tms:utime tms-start tms-end)
|
||||||
(get tms:stime tms-start tms-end)
|
(get tms:stime tms-start tms-end)
|
||||||
(get tms:cutime tms-start tms-end)
|
(get tms:cutime tms-start tms-end)
|
||||||
(get tms:cstime tms-start tms-end)
|
(get tms:cstime tms-start tms-end)
|
||||||
(get id gc-start gc-end))
|
(get id gc-start gc-end))
|
||||||
result))
|
result))
|
||||||
|
|
||||||
|
(define-macro (time exp)
|
||||||
|
`(,time-proc (lambda () ,exp)))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue