diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-09-26 00:02:21 -0400 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2012-09-26 00:02:21 -0400 |
commit | 234148bf943ffce55121aefc8694889eb08b0daa (patch) | |
tree | 452f66cfbbc026717c86835bac900f74018093dd /lisp/profiler.el | |
parent | 611b7507a8eb63d0c3fd8b5c6182920453292688 (diff) | |
download | emacs-234148bf943ffce55121aefc8694889eb08b0daa.tar.gz |
* lisp/profiler.el (profiler-start): Don't prompt for choice when thereold-branches/profiler
isn't any.
(profiler-stop): Use new semantics of profiler-*-stop.
(profiler-reset, profiler--report-cpu): Don't signal an error if the
cpu profiler is not available.
* src/profiler.c (Fprofiler_cpu_stop, Fprofiler_memory_stop):
Return whether the profiler was running, instead of signaling an error
if it wasn't.
Diffstat (limited to 'lisp/profiler.el')
-rw-r--r-- | lisp/profiler.el | 33 |
1 files changed, 14 insertions, 19 deletions
diff --git a/lisp/profiler.el b/lisp/profiler.el index fb38b00c2d8..91bd744fb35 100644 --- a/lisp/profiler.el +++ b/lisp/profiler.el @@ -574,9 +574,10 @@ MODE can be one of `cpu', `mem', or `cpu+mem'. If MODE is `cpu' or `cpu+mem', time-based profiler will be started. Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." (interactive - (list (intern (completing-read "Mode (default cpu): " - '("cpu" "mem" "cpu+mem") - nil t nil nil "cpu")))) + (list (if (not (fboundp 'profiler-cpu-start)) 'mem + (intern (completing-read "Mode (default cpu): " + '("cpu" "mem" "cpu+mem") + nil t nil nil "cpu"))))) (cl-ecase mode (cpu (profiler-cpu-start profiler-sample-interval) @@ -592,30 +593,24 @@ Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." (defun profiler-stop () "Stop started profilers. Profiler logs will be kept." (interactive) - (cond - ((and (profiler-cpu-running-p) - (profiler-memory-running-p)) - (profiler-cpu-stop) - (profiler-memory-stop) - (message "CPU and memory profiler stopped")) - ((profiler-cpu-running-p) - (profiler-cpu-stop) - (message "CPU profiler stopped")) - ((profiler-memory-running-p) - (profiler-memory-stop) - (message "Memory profiler stopped")) - (t - (error "No profilers started")))) + (let ((cpu (if (fboundp 'profiler-cpu-stop) (profiler-cpu-stop))) + (mem (profiler-memory-stop))) + (message "%s profiler stopped" + (cond ((and mem cpu) "CPU and memory") + (mem "Memory") + (cpu "CPU") + (t "No"))))) (defun profiler-reset () "Reset profiler log." (interactive) - (ignore (profiler-cpu-log)) + (when (fboundp 'profiler-cpu-log) + (ignore (profiler-cpu-log))) (ignore (profiler-memory-log)) t) (defun profiler--report-cpu () - (let ((log (profiler-cpu-log))) + (let ((log (if (fboundp 'profiler-cpu-log) (profiler-cpu-log)))) (when log (puthash 'type 'cpu log) (puthash 'timestamp (current-time) log) |