summaryrefslogtreecommitdiff
path: root/lisp/profiler.el
diff options
context:
space:
mode:
authorGlenn Morris <rgm@gnu.org>2013-01-19 18:39:59 -0800
committerGlenn Morris <rgm@gnu.org>2013-01-19 18:39:59 -0800
commit15df6fa4f12fdb2faf798b88c544b31de83591b2 (patch)
tree73a84cfeedc9712d0e870ee6263020cfcd17dd4e /lisp/profiler.el
parentee271528bfa645727f03c2a3e04db73b72a76077 (diff)
downloademacs-15df6fa4f12fdb2faf798b88c544b31de83591b2.tar.gz
profiler.el tweaks
* profiler.el (profiler-running-p): New function. (profiler-cpu-profile): Use profiler-running-p. (profiler-report-mode-map): Add some more menu entries.
Diffstat (limited to 'lisp/profiler.el')
-rw-r--r--lisp/profiler.el20
1 files changed, 16 insertions, 4 deletions
diff --git a/lisp/profiler.el b/lisp/profiler.el
index 2a4a9013986..9c73fc6e590 100644
--- a/lisp/profiler.el
+++ b/lisp/profiler.el
@@ -200,11 +200,18 @@ function name of a function itself."
(goto-char (point-min))
(read (current-buffer))))
+(defun profiler-running-p (&optional mode)
+ "Return non-nil if the profiler is running.
+Optional argument MODE means only check for the specified mode (cpu or mem)."
+ (cond ((eq mode 'cpu) (and (fboundp 'profiler-cpu-running-p)
+ (profiler-cpu-running-p)))
+ ((eq mode 'mem) (profiler-memory-running-p))
+ (t (or (profiler-running-p 'cpu)
+ (profiler-running-p 'mem)))))
+
(defun profiler-cpu-profile ()
"Return CPU profile."
- (when (and (fboundp 'profiler-cpu-running-p)
- (fboundp 'profiler-cpu-log)
- (profiler-cpu-running-p))
+ (when (profiler-running-p 'cpu)
(profiler-make-profile
:type 'cpu
:timestamp (current-time)
@@ -457,7 +464,12 @@ RET: expand or collapse"))
["Compare Profile..." profiler-report-compare-profile :active t
:help "Compare current profile with another"]
["Write Profile..." profiler-report-write-profile :active t
- :help "Write current profile to a file"]))
+ :help "Write current profile to a file"]
+ "--"
+ ["Stop Profiler" profiler-stop :active (profiler-running-p)
+ :help "Stop profiling"]
+ ["New Report" profiler-report :active (profiler-running-p)
+ :help "Make a new report"]))
map)
"Keymap for `profiler-report-mode'.")