summaryrefslogtreecommitdiff
path: root/module/statprof.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2014-04-14 17:06:05 +0200
committerAndy Wingo <wingo@pobox.com>2014-04-14 17:06:05 +0200
commitda169db26ae3ac4c2440b1fcb678cfd18392c5aa (patch)
treea2ff621ab274fa571a05043f08248306cf78b577 /module/statprof.scm
parenta234ab929c65f0627a38131ad6c42f16b3aeae9c (diff)
downloadguile-da169db26ae3ac4c2440b1fcb678cfd18392c5aa.tar.gz
statprof avoids mucking with VM trace levels when not counting calls
* module/statprof.scm (statprof-start, statprof-stop): Don't futz the vm trace level when we aren't counting calls. With this change, statprof now imposes no overhead on the measured program.
Diffstat (limited to 'module/statprof.scm')
-rw-r--r--module/statprof.scm10
1 files changed, 5 insertions, 5 deletions
diff --git a/module/statprof.scm b/module/statprof.scm
index 49b77cf74..b9d4702c5 100644
--- a/module/statprof.scm
+++ b/module/statprof.scm
@@ -403,8 +403,8 @@ than @code{statprof-stop}, @code{#f} otherwise."
(set-prev-sigprof-handler! state (car prev)))
(reset-sigprof-timer (if (zero? rpt) (sampling-period state) rpt))
(when (call-counts state)
- (add-hook! (vm-apply-hook) count-call))
- (set-vm-trace-level! (1+ (vm-trace-level)))
+ (add-hook! (vm-apply-hook) count-call)
+ (set-vm-trace-level! (1+ (vm-trace-level))))
#t)))
;; Do not call this from statprof internal functions -- user only.
@@ -414,12 +414,12 @@ than @code{statprof-stop}, @code{#f} otherwise."
;; signals here, but if I'm wrong, please let me know.
(set-profile-level! state (- (profile-level state) 1))
(when (zero? (profile-level state))
+ (when (call-counts state)
+ (set-vm-trace-level! (1- (vm-trace-level)))
+ (remove-hook! (vm-apply-hook) count-call))
(set-gc-time-taken! state
(- (assq-ref (gc-stats) 'gc-time-taken)
(gc-time-taken state)))
- (set-vm-trace-level! (1- (vm-trace-level)))
- (when (call-counts state)
- (remove-hook! (vm-apply-hook) count-call))
;; I believe that we need to do this before getting the time
;; (unless we want to make things even more complicated).
(set-remaining-prof-time! state (reset-sigprof-timer 0))