mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-22 04:30:19 +02:00
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.
This commit is contained in:
parent
21b6df302f
commit
c1e3e9aaff
1 changed files with 10 additions and 12 deletions
|
@ -485,21 +485,19 @@ Disassemble a file."
|
||||||
"time EXP
|
"time EXP
|
||||||
Time execution."
|
Time execution."
|
||||||
(let* ((gc-start (gc-run-time))
|
(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)))
|
(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)))
|
(gc-end (gc-run-time)))
|
||||||
(define (get proc start end)
|
(define (diff start end)
|
||||||
(exact->inexact (/ (- (proc end) (proc start)) internal-time-units-per-second)))
|
(/ (- end start) 1.0 internal-time-units-per-second))
|
||||||
(repl-print repl result)
|
(repl-print repl result)
|
||||||
(display "clock utime stime cutime cstime gctime\n")
|
(format #t ";; ~,6Fs real time, ~,6Fs run time. ~,6Fs spent in GC.\n"
|
||||||
(format #t "~5,2F ~5,2F ~5,2F ~6,2F ~6,2F ~6,2F\n"
|
(diff real-start real-end)
|
||||||
(get tms:clock tms-start tms-end)
|
(diff run-start run-end)
|
||||||
(get tms:utime tms-start tms-end)
|
(diff gc-start gc-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))
|
|
||||||
result))
|
result))
|
||||||
|
|
||||||
(define-meta-command (profile repl (form) . opts)
|
(define-meta-command (profile repl (form) . opts)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue