summaryrefslogtreecommitdiff
path: root/module/statprof.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2014-02-28 19:42:04 +0100
committerAndy Wingo <wingo@pobox.com>2014-02-28 19:42:04 +0100
commite3997e709bef073d844148b0b5720ec19472014f (patch)
tree286711f6716abdb1feece5b728c0521535755094 /module/statprof.scm
parentcd073eb4a970eb77b3ef92d4a3e4daac4c8177dd (diff)
downloadguile-e3997e709bef073d844148b0b5720ec19472014f.tar.gz
Refactorings: call-data has source, stats is a record
* module/statprof.scm (call-data): Add source member. (stack-samples->procedure-data): Populate source member (stats): Convert to record from vector. (statprof-call-data->stats): Adapt to produce a record.
Diffstat (limited to 'module/statprof.scm')
-rw-r--r--module/statprof.scm62
1 files changed, 31 insertions, 31 deletions
diff --git a/module/statprof.scm b/module/statprof.scm
index b1b638203..4310c0f94 100644
--- a/module/statprof.scm
+++ b/module/statprof.scm
@@ -371,9 +371,11 @@ always collects full stacks.)"
(values))
(define-record-type call-data
- (make-call-data name printable call-count cum-sample-count self-sample-count)
+ (make-call-data name source printable
+ call-count cum-sample-count self-sample-count)
call-data?
(name call-data-name)
+ (source call-data-source)
(printable call-data-printable)
(call-count call-data-call-count set-call-data-call-count!)
(cum-sample-count call-data-cum-sample-count set-call-data-cum-sample-count!)
@@ -423,6 +425,7 @@ always collects full stacks.)"
(entry (if pdi (program-debug-info-addr pdi) addr)))
(or (hashv-ref table entry)
(let ((data (make-call-data (and=> pdi program-debug-info-name)
+ (find-source-for-addr entry)
(addr->printable entry pdi)
(and call-counts
(hashv-ref call-counts entry))
@@ -441,6 +444,7 @@ always collects full stacks.)"
;; a primitive
((symbol? callee) callee)
(else #f))
+ #f
(with-output-to-string (lambda () (write callee)))
(and call-counts (hashv-ref call-counts callee))
0
@@ -518,16 +522,20 @@ none is available."
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Stats
+(define-record-type stats
+ (make-stats proc-name %-time-in-proc cum-secs-in-proc self-secs-in-proc
+ calls self-secs-per-call cum-secs-per-call)
+ stats?
+ (proc-name statprof-stats-proc-name)
+ (%-time-in-proc statprof-stats-%-time-in-proc)
+ (cum-secs-in-proc statprof-stats-cum-secs-in-proc)
+ (self-secs-in-proc statprof-stats-self-secs-in-proc)
+ (calls statprof-stats-calls)
+ (self-secs-per-call statprof-stats-self-secs-per-call)
+ (cum-secs-per-call statprof-stats-cum-secs-per-call))
+
(define (statprof-call-data->stats call-data)
"Returns an object of type @code{statprof-stats}."
- ;; returns (vector proc-name
- ;; %-time-in-proc
- ;; cum-seconds-in-proc
- ;; self-seconds-in-proc
- ;; num-calls
- ;; self-secs-per-call
- ;; total-secs-per-call)
-
(define state (existing-profiler-state))
(let* ((proc-name (call-data-printable call-data))
@@ -539,28 +547,20 @@ none is available."
(num-calls (and (call-counts state)
(statprof-call-data-calls call-data))))
- (vector proc-name
- (* (/ self-samples all-samples) 100.0)
- (* cum-samples secs-per-sample 1.0)
- (* self-samples secs-per-sample 1.0)
- num-calls
- (and num-calls ;; maybe we only sampled in children
- (if (zero? self-samples) 0.0
- (/ (* self-samples secs-per-sample) 1.0 num-calls)))
- (and num-calls ;; cum-samples must be positive
- (/ (* cum-samples secs-per-sample)
- 1.0
- ;; num-calls might be 0 if we entered statprof during the
- ;; dynamic extent of the call
- (max num-calls 1))))))
-
-(define (statprof-stats-proc-name stats) (vector-ref stats 0))
-(define (statprof-stats-%-time-in-proc stats) (vector-ref stats 1))
-(define (statprof-stats-cum-secs-in-proc stats) (vector-ref stats 2))
-(define (statprof-stats-self-secs-in-proc stats) (vector-ref stats 3))
-(define (statprof-stats-calls stats) (vector-ref stats 4))
-(define (statprof-stats-self-secs-per-call stats) (vector-ref stats 5))
-(define (statprof-stats-cum-secs-per-call stats) (vector-ref stats 6))
+ (make-stats proc-name
+ (* (/ self-samples all-samples) 100.0)
+ (* cum-samples secs-per-sample 1.0)
+ (* self-samples secs-per-sample 1.0)
+ num-calls
+ (and num-calls ;; maybe we only sampled in children
+ (if (zero? self-samples) 0.0
+ (/ (* self-samples secs-per-sample) 1.0 num-calls)))
+ (and num-calls ;; cum-samples must be positive
+ (/ (* cum-samples secs-per-sample)
+ 1.0
+ ;; num-calls might be 0 if we entered statprof during the
+ ;; dynamic extent of the call
+ (max num-calls 1))))))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;