summaryrefslogtreecommitdiff
path: root/module/system/repl/command.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2011-07-06 14:01:03 +0200
committerAndy Wingo <wingo@pobox.com>2011-07-07 09:57:19 +0200
commitc1e3e9aafff8ef669fd3573f7c92d2f5ff7c2d66 (patch)
tree5177ef1a0e66805c8788c9ecf7b5cb95e2588bd0 /module/system/repl/command.scm
parent21b6df302fbc372a4b359f73a7441752cd6c1306 (diff)
downloadguile-c1e3e9aafff8ef669fd3573f7c92d2f5ff7c2d66.tar.gz
more precision for ,time
* module/system/repl/command.scm (time): Use the high-precision timers instead of stime(2). Changes the output format of `,time' too; perhaps there is a better way.
Diffstat (limited to 'module/system/repl/command.scm')
-rw-r--r--module/system/repl/command.scm22
1 files changed, 10 insertions, 12 deletions
diff --git a/module/system/repl/command.scm b/module/system/repl/command.scm
index 109b533f8..a2f2a6f84 100644
--- a/module/system/repl/command.scm
+++ b/module/system/repl/command.scm
@@ -485,21 +485,19 @@ Disassemble a file."
"time EXP
Time execution."
(let* ((gc-start (gc-run-time))
- (tms-start (times))
+ (real-start (get-internal-real-time))
+ (run-start (get-internal-run-time))
(result (repl-eval repl (repl-parse repl form)))
- (tms-end (times))
+ (run-end (get-internal-run-time))
+ (real-end (get-internal-real-time))
(gc-end (gc-run-time)))
- (define (get proc start end)
- (exact->inexact (/ (- (proc end) (proc start)) internal-time-units-per-second)))
+ (define (diff start end)
+ (/ (- end start) 1.0 internal-time-units-per-second))
(repl-print repl result)
- (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 identity gc-start gc-end))
+ (format #t ";; ~,6Fs real time, ~,6Fs run time. ~,6Fs spent in GC.\n"
+ (diff real-start real-end)
+ (diff run-start run-end)
+ (diff gc-start gc-end))
result))
(define-meta-command (profile repl (form) . opts)