From da169db26ae3ac4c2440b1fcb678cfd18392c5aa Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 14 Apr 2014 17:06:05 +0200 Subject: 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. --- module/statprof.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'module/statprof.scm') 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)) -- cgit v1.2.3