mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-09 21:40:33 +02:00
statprof-active? instead of checking profile level
* module/statprof.scm (statprof-reset, statprof-fold-call-data): (statprof-proc-call-data, statprof-accumulated-time): (statprof-sample-count): Refactor some things to use statprof-active? instead of checking the profile level manually.
This commit is contained in:
parent
4eb1fb9b8a
commit
4d0c358b4c
1 changed files with 12 additions and 19 deletions
|
@ -415,7 +415,7 @@ 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."
|
||||||
(when (and (profiler-state) (positive? (profile-level (profiler-state))))
|
(when (statprof-active?)
|
||||||
(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?
|
(let ((state (fresh-profiler-state #:count-calls? count-calls?
|
||||||
#:sampling-frequency
|
#:sampling-frequency
|
||||||
|
@ -432,24 +432,19 @@ called while statprof is active. @var{proc} should take two arguments,
|
||||||
|
|
||||||
Note that a given proc-name may appear multiple times, but if it does,
|
Note that a given proc-name may appear multiple times, but if it does,
|
||||||
it represents different functions with the same name."
|
it represents different functions with the same name."
|
||||||
(define state (existing-profiler-state))
|
(when (statprof-active?)
|
||||||
(if (positive? (profile-level state))
|
(error "Can't call statprof-fold-call-data while profiler is running."))
|
||||||
(error "Can't call statprof-fold-called while profiler is running."))
|
|
||||||
|
|
||||||
(hash-fold
|
(hash-fold
|
||||||
(lambda (key value prior-result)
|
(lambda (key value prior-result)
|
||||||
(proc value prior-result))
|
(proc value prior-result))
|
||||||
init
|
init
|
||||||
(procedure-data state)))
|
(procedure-data (existing-profiler-state))))
|
||||||
|
|
||||||
(define (statprof-proc-call-data proc)
|
(define (statprof-proc-call-data proc)
|
||||||
"Returns the call-data associated with @var{proc}, or @code{#f} if
|
"Returns the call-data associated with @var{proc}, or @code{#f} if
|
||||||
none is available."
|
none is available."
|
||||||
(define state (existing-profiler-state))
|
(when (statprof-active?)
|
||||||
|
(error "Can't call statprof-proc-call-data while profiler is running."))
|
||||||
(if (positive? (profile-level state))
|
|
||||||
(error "Can't call statprof-fold-called while profiler is running."))
|
|
||||||
|
|
||||||
(get-call-data proc))
|
(get-call-data proc))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
@ -582,17 +577,15 @@ statistics.@code{}"
|
||||||
|
|
||||||
(define (statprof-accumulated-time)
|
(define (statprof-accumulated-time)
|
||||||
"Returns the time accumulated during the last statprof run.@code{}"
|
"Returns the time accumulated during the last statprof run.@code{}"
|
||||||
(define state (existing-profiler-state))
|
(when (statprof-active?)
|
||||||
(if (positive? (profile-level state))
|
(error "Can't get accumulated time while profiler is running."))
|
||||||
(error "Can't get accumulated time while profiler is running."))
|
(/ (accumulated-time (existing-profiler-state)) internal-time-units-per-second))
|
||||||
(/ (accumulated-time state) internal-time-units-per-second))
|
|
||||||
|
|
||||||
(define (statprof-sample-count)
|
(define (statprof-sample-count)
|
||||||
"Returns the number of samples taken during the last statprof run.@code{}"
|
"Returns the number of samples taken during the last statprof run.@code{}"
|
||||||
(define state (existing-profiler-state))
|
(when (statprof-active?)
|
||||||
(if (positive? (profile-level state))
|
(error "Can't get sample count while profiler is running."))
|
||||||
(error "Can't get accumulated time while profiler is running."))
|
(sample-count (existing-profiler-state)))
|
||||||
(sample-count state))
|
|
||||||
|
|
||||||
(define statprof-call-data-name call-data-name)
|
(define statprof-call-data-name call-data-name)
|
||||||
(define statprof-call-data-calls call-data-call-count)
|
(define statprof-call-data-calls call-data-call-count)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue