~ chicken-core (chicken-5) 9bdcc7ea41018947036e22dc09524fc901c9c413
commit 9bdcc7ea41018947036e22dc09524fc901c9c413 Author: felix <felix@call-with-current-continuation.org> AuthorDate: Tue Aug 2 09:09:06 2011 +0200 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Tue Aug 2 09:09:06 2011 +0200 profile-unit is compiled unsafe; fixed incorrect % calculation in chicken-profile (thanks to Sven hartrumpf) diff --git a/chicken-profile.scm b/chicken-profile.scm index 257591ed..5a28eb36 100644 --- a/chicken-profile.scm +++ b/chicken-profile.scm @@ -182,31 +182,28 @@ EOF (define (write-profile) (print "reading `" file "' ...\n") - (let* ([data0 (with-input-from-file file read-profile)] - [max-t (fold (lambda (t result) - (+ (third t) result)) - 0 - data0)] - [data (sort (map + (let* ((data0 (with-input-from-file file read-profile)) + (max-t (foldl (lambda (r t) (max r (third t))) 0 data0)) + (data (sort (map (lambda (t) (append t - (let ((c (second t)) - (t (third t))) - (list (or (and c (> c 0) (/ t c)) + (let ((c (second t)) ; count + (t (third t))) ; total time + (list (or (and c (> c 0) (/ t c)) ; time / count 0) - (or (and (> max-t 0) (* (/ t max-t) 100)) + (or (and (> max-t 0) (* (/ t max-t) 100)) ; % of max-time 0) )))) data0) - sort-by)]) + sort-by))) (if (< 0 top (length data)) (set! data (take data top))) (set! data (map (lambda (entry) - (let ([c (second entry)] - [t (third entry)] - [a (fourth entry)] - [p (fifth entry)] ) + (let ([c (second entry)] ; count + [t (third entry)] ; total time + [a (fourth entry)] ; average time + [p (fifth entry)] ) ; % of max time (list (##sys#symbol->qualified-string (first entry)) (if (not c) "overflow" (number->string c)) (format-real (/ t 1000) seconds-digits) diff --git a/profiler.scm b/profiler.scm index 1879b461..4ba7cb93 100644 --- a/profiler.scm +++ b/profiler.scm @@ -28,6 +28,7 @@ (declare (unit profiler) (hide ##sys#profile-name ##sys#profile-vector-list cpu-ms) + (unsafe) (disable-interrupts)) (foreign-declare #<<EOFTrap