* time.scm (time): Reimplemented as a procedure call.
authorKeisuke Nishida <kxn30@po.cwru.edu>
Wed, 21 Mar 2001 02:25:48 +0000 (02:25 +0000)
committerKeisuke Nishida <kxn30@po.cwru.edu>
Wed, 21 Mar 2001 02:25:48 +0000 (02:25 +0000)
(Thanks to Marius Vollmer)

ice-9/ChangeLog
ice-9/time.scm

index 6342777..1625cf3 100644 (file)
@@ -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.
index 0be666c..828b2d5 100644 (file)
   :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)))