Added WITH-TIMINGS, a general procedure timing device.
authorStephen Adams <edu/mit/csail/zurich/adams>
Tue, 8 Aug 1995 15:31:05 +0000 (15:31 +0000)
committerStephen Adams <edu/mit/csail/zurich/adams>
Tue, 8 Aug 1995 15:31:05 +0000 (15:31 +0000)
v7/src/runtime/sysclk.scm

index 45397af78da4deff6e1ae293e6c1efeab1d3e10f..10e7473a5152394eeb26097a2397b1e08fed165e 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/sysclk.scm,v 14.2 1989/11/28 01:28:19 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/sysclk.scm,v 14.3 1995/08/08 15:31:05 adams Exp $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -78,4 +78,20 @@ MIT in each case. |#
   (/ (exact->inexact ticks) 1000))
 
 (define (internal-time/seconds->ticks seconds)
-  (round->exact (* seconds 1000)))
\ No newline at end of file
+  (round->exact (* seconds 1000)))
+
+(define (with-timings thunk receiver)
+  (let ((process-start  (process-time-clock))
+       (gc-time-start  non-runtime)
+       (real-start     (real-time-clock)))
+    (let ((value (thunk)))
+      (let ((process-end  (process-time-clock))
+           (gc-time-end  non-runtime)
+           (real-end     (real-time-clock)))
+       (let ((process-time (- process-end process-start))
+             (gc-time      (- gc-time-end gc-time-start))
+             (real-time    (- real-end real-start)))
+         (receiver (- process-time gc-time)
+                   gc-time
+                   real-time)
+         value)))))
\ No newline at end of file