* Fixed bug in collecting bignums.
* time-it now displays the number of collections and bytes allocated.
This commit is contained in:
Binary file not shown.
+1
-1
@@ -4888,7 +4888,7 @@
|
||||
(for-each
|
||||
(lambda (ls)
|
||||
(newline)
|
||||
(for-each (lambda (x) (printf " ~s\n" x)) (cdr ls)))
|
||||
(for-each (lambda (x) (printf " ~s\n" x)) ls))
|
||||
ls*)))
|
||||
(let ([code* (list*->code*
|
||||
(lambda (x)
|
||||
|
||||
+34
-9
@@ -1,15 +1,16 @@
|
||||
|
||||
(let ()
|
||||
(define-record stats
|
||||
(user-secs user-usecs sys-secs sys-usecs real-secs real-usecs))
|
||||
(user-secs user-usecs sys-secs sys-usecs real-secs real-usecs
|
||||
collection-id))
|
||||
|
||||
(define (mk-stats)
|
||||
(make-stats #f #f #f #f #f #f))
|
||||
(make-stats #f #f #f #f #f #f #f))
|
||||
|
||||
(define (set-stats! t)
|
||||
(foreign-call "ikrt_stats_now" t))
|
||||
|
||||
(define (print-stats message t1 t0)
|
||||
(define (print-stats message bytes t1 t0)
|
||||
(define (print-time msg secs usecs)
|
||||
(if (fx< usecs 0)
|
||||
(print-time msg (fx- secs 1) (fx+ usecs 1000000))
|
||||
@@ -22,6 +23,13 @@
|
||||
(if message
|
||||
(printf "running stats for ~a:\n" message)
|
||||
(printf "running stats:\n"))
|
||||
(let ([collections
|
||||
(fx- (stats-collection-id t1) (stats-collection-id t0))])
|
||||
(case collections
|
||||
[(0) (display " no collections\n")]
|
||||
[(1) (display " 1 collection\n")]
|
||||
[else (printf " ~a collections\n" collections)]))
|
||||
|
||||
(print-time "user"
|
||||
(fx- (stats-user-secs t1) (stats-user-secs t0))
|
||||
(fx- (stats-user-usecs t1) (stats-user-usecs t0)))
|
||||
@@ -30,7 +38,8 @@
|
||||
(fx- (stats-sys-usecs t1) (stats-sys-usecs t0)))
|
||||
(print-time "real"
|
||||
(fx- (stats-real-secs t1) (stats-real-secs t0))
|
||||
(fx- (stats-real-usecs t1) (stats-real-usecs t0))))
|
||||
(fx- (stats-real-usecs t1) (stats-real-usecs t0)))
|
||||
(printf " ~a bytes allocated\n" bytes))
|
||||
|
||||
(define time-it
|
||||
(case-lambda
|
||||
@@ -39,20 +48,36 @@
|
||||
[(proc message)
|
||||
(unless (procedure? proc)
|
||||
(error 'time-it "~s is not a procedure" proc))
|
||||
(let* ([t1 (mk-stats)]
|
||||
[t0 (mk-stats)])
|
||||
(let* ([t0 (mk-stats)]
|
||||
[t1 (mk-stats)]
|
||||
[bytes-min (bytes-minor)]
|
||||
[bytes-maj (bytes-major)])
|
||||
(set-stats! t0)
|
||||
(call-with-values proc
|
||||
(case-lambda
|
||||
[(v)
|
||||
(set-stats! t1)
|
||||
(print-stats message t1 t0)
|
||||
(print-stats message
|
||||
(diff-bytes bytes-min bytes-maj
|
||||
(bytes-minor) (bytes-major))
|
||||
t1 t0)
|
||||
v]
|
||||
[v*
|
||||
(set-stats! t1)
|
||||
(print-stats message t1 t0)
|
||||
(print-stats message
|
||||
(diff-bytes bytes-min bytes-maj
|
||||
(bytes-minor) (bytes-major))
|
||||
t1 t0)
|
||||
(apply values v*)])))]))
|
||||
|
||||
|
||||
(define (bytes-minor)
|
||||
(foreign-call "ikrt_bytes_allocated"))
|
||||
(define (bytes-major)
|
||||
(foreign-call "ikrt_bytes_allocated_major"))
|
||||
(define (diff-bytes mnr0 mjr0 mnr1 mjr1)
|
||||
(+ (fx- mnr1 mnr0) (* (fx- mjr1 mjr0) #x10000000)))
|
||||
|
||||
(primitive-set! 'time-it time-it)
|
||||
|
||||
|
||||
)
|
||||
|
||||
+1
-1
@@ -85,7 +85,7 @@
|
||||
negative? zero? number->string logand = < > <= >=
|
||||
make-guardian weak-cons collect
|
||||
interrupt-handler
|
||||
time-it
|
||||
time-it
|
||||
))
|
||||
|
||||
(define system-primitives
|
||||
|
||||
Reference in New Issue
Block a user