mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
statprof-reset creates a new state
* module/statprof.scm (fresh-profiler-state): New helper. (ensure-profiler-state): Use it. (accumulate-time): No need to add 0.0 here. (statprof-reset): Create a new state instead of mutating the existing one.
This commit is contained in:
parent
45a7de8268
commit
4eb1fb9b8a
1 changed files with 16 additions and 16 deletions
|
@ -194,9 +194,15 @@
|
||||||
|
|
||||||
(define profiler-state (make-parameter #f))
|
(define profiler-state (make-parameter #f))
|
||||||
|
|
||||||
|
(define* (fresh-profiler-state #:key (count-calls? #f)
|
||||||
|
(sampling-frequency '(0 . 10000))
|
||||||
|
(full-stacks? #f))
|
||||||
|
(make-state 0.0 #f 0 sampling-frequency #f 0 count-calls? 0.0 #f '()
|
||||||
|
(make-hash-table) #f))
|
||||||
|
|
||||||
(define (ensure-profiler-state)
|
(define (ensure-profiler-state)
|
||||||
(or (profiler-state)
|
(or (profiler-state)
|
||||||
(let ((state (make-state #f #f #f #f #f 0 #t 0 #f '() #f #f)))
|
(let ((state (fresh-profiler-state)))
|
||||||
(profiler-state state)
|
(profiler-state state)
|
||||||
state)))
|
state)))
|
||||||
|
|
||||||
|
@ -227,7 +233,6 @@
|
||||||
(define (accumulate-time state stop-time)
|
(define (accumulate-time state stop-time)
|
||||||
(set-accumulated-time! state
|
(set-accumulated-time! state
|
||||||
(+ (accumulated-time state)
|
(+ (accumulated-time state)
|
||||||
0.0
|
|
||||||
(- stop-time (last-start-time state)))))
|
(- stop-time (last-start-time state)))))
|
||||||
|
|
||||||
(define (get-call-data proc)
|
(define (get-call-data proc)
|
||||||
|
@ -410,20 +415,15 @@ data. If @var{full-stacks?} is true, collect all sampled stacks into a
|
||||||
list for later analysis.
|
list for later analysis.
|
||||||
|
|
||||||
Enables traps and debugging as necessary."
|
Enables traps and debugging as necessary."
|
||||||
(define state (ensure-profiler-state))
|
(when (and (profiler-state) (positive? (profile-level (profiler-state))))
|
||||||
(if (positive? (profile-level state))
|
(error "Can't reset profiler while profiler is running."))
|
||||||
(error "Can't reset profiler while profiler is running."))
|
(let ((state (fresh-profiler-state #:count-calls? count-calls?
|
||||||
(set-count-calls?! state count-calls?)
|
#:sampling-frequency
|
||||||
(set-accumulated-time! state 0)
|
(cons sample-seconds sample-microseconds)
|
||||||
(set-last-start-time! state #f)
|
#:full-stacks? full-stacks?)))
|
||||||
(set-sample-count! state 0)
|
(profiler-state state)
|
||||||
(set-sampling-frequency! state (cons sample-seconds sample-microseconds))
|
(sigaction SIGPROF profile-signal-handler)
|
||||||
(set-remaining-prof-time! state #f)
|
#t))
|
||||||
(set-procedure-data! state (make-hash-table 131))
|
|
||||||
(set-record-full-stacks?! state full-stacks?)
|
|
||||||
(set-stacks! state '())
|
|
||||||
(sigaction SIGPROF profile-signal-handler)
|
|
||||||
#t)
|
|
||||||
|
|
||||||
(define (statprof-fold-call-data proc init)
|
(define (statprof-fold-call-data proc init)
|
||||||
"Fold @var{proc} over the call-data accumulated by statprof. Cannot be
|
"Fold @var{proc} over the call-data accumulated by statprof. Cannot be
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue