1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

statprof and gcprof procedures use a fresh statprof state

* module/statprof.scm (statprof, gcprof): Create a fresh statprof
  state.
This commit is contained in:
Andy Wingo 2014-02-25 22:16:49 +01:00
parent 4b3d7a2b7c
commit fd5dfcce80

View file

@ -658,8 +658,8 @@ If @var{full-stacks?} is true, at each sample, statprof will store away the
whole call tree, for later analysis. Use @code{statprof-fetch-stacks} or whole call tree, for later analysis. Use @code{statprof-fetch-stacks} or
@code{statprof-fetch-call-tree} to retrieve the last-stored stacks." @code{statprof-fetch-call-tree} to retrieve the last-stored stacks."
(define state (ensure-profiler-state)) (let ((state (fresh-profiler-state)))
(parameterize ((profiler-state state))
(dynamic-wind (dynamic-wind
(lambda () (lambda ()
(statprof-reset (inexact->exact (floor (/ 1 hz))) (statprof-reset (inexact->exact (floor (/ 1 hz)))
@ -675,8 +675,7 @@ whole call tree, for later analysis. Use @code{statprof-fetch-stacks} or
(lp (1- i))))) (lp (1- i)))))
(lambda () (lambda ()
(statprof-stop) (statprof-stop)
(statprof-display) (statprof-display))))))
(set-procedure-data! state #f))))
(define-macro (with-statprof . args) (define-macro (with-statprof . args)
"Profiles the expressions in its body. "Profiles the expressions in its body.
@ -732,7 +731,8 @@ If @var{full-stacks?} is true, at each sample, statprof will store away the
whole call tree, for later analysis. Use @code{statprof-fetch-stacks} or whole call tree, for later analysis. Use @code{statprof-fetch-stacks} or
@code{statprof-fetch-call-tree} to retrieve the last-stored stacks." @code{statprof-fetch-call-tree} to retrieve the last-stored stacks."
(define state (ensure-profiler-state)) (let ((state (fresh-profiler-state)))
(parameterize ((profiler-state state))
(define (reset) (define (reset)
(when (positive? (profile-level state)) (when (positive? (profile-level state))
@ -795,5 +795,4 @@ whole call tree, for later analysis. Use @code{statprof-fetch-stacks} or
(lp (1- i))))) (lp (1- i)))))
(lambda () (lambda ()
(stop) (stop)
(statprof-display) (statprof-display))))))
(set-procedure-data! state #f))))