aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/profiler.el
diff options
context:
space:
mode:
authorStefan Monnier2012-09-26 00:02:21 -0400
committerStefan Monnier2012-09-26 00:02:21 -0400
commit234148bf943ffce55121aefc8694889eb08b0daa (patch)
tree452f66cfbbc026717c86835bac900f74018093dd /lisp/profiler.el
parent611b7507a8eb63d0c3fd8b5c6182920453292688 (diff)
downloademacs-old-branches/profiler.tar.gz
emacs-old-branches/profiler.zip
* 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.el33
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'.
574If MODE is `cpu' or `cpu+mem', time-based profiler will be started. 574If MODE is `cpu' or `cpu+mem', time-based profiler will be started.
575Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." 575Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
576 (interactive 576 (interactive
577 (list (intern (completing-read "Mode (default cpu): " 577 (list (if (not (fboundp 'profiler-cpu-start)) 'mem
578 '("cpu" "mem" "cpu+mem") 578 (intern (completing-read "Mode (default cpu): "
579 nil t nil nil "cpu")))) 579 '("cpu" "mem" "cpu+mem")
580 nil t nil nil "cpu")))))
580 (cl-ecase mode 581 (cl-ecase mode
581 (cpu 582 (cpu
582 (profiler-cpu-start profiler-sample-interval) 583 (profiler-cpu-start profiler-sample-interval)
@@ -592,30 +593,24 @@ Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started."
592(defun profiler-stop () 593(defun profiler-stop ()
593 "Stop started profilers. Profiler logs will be kept." 594 "Stop started profilers. Profiler logs will be kept."
594 (interactive) 595 (interactive)
595 (cond 596 (let ((cpu (if (fboundp 'profiler-cpu-stop) (profiler-cpu-stop)))
596 ((and (profiler-cpu-running-p) 597 (mem (profiler-memory-stop)))
597 (profiler-memory-running-p)) 598 (message "%s profiler stopped"
598 (profiler-cpu-stop) 599 (cond ((and mem cpu) "CPU and memory")
599 (profiler-memory-stop) 600 (mem "Memory")
600 (message "CPU and memory profiler stopped")) 601 (cpu "CPU")
601 ((profiler-cpu-running-p) 602 (t "No")))))
602 (profiler-cpu-stop)
603 (message "CPU profiler stopped"))
604 ((profiler-memory-running-p)
605 (profiler-memory-stop)
606 (message "Memory profiler stopped"))
607 (t
608 (error "No profilers started"))))
609 603
610(defun profiler-reset () 604(defun profiler-reset ()
611 "Reset profiler log." 605 "Reset profiler log."
612 (interactive) 606 (interactive)
613 (ignore (profiler-cpu-log)) 607 (when (fboundp 'profiler-cpu-log)
608 (ignore (profiler-cpu-log)))
614 (ignore (profiler-memory-log)) 609 (ignore (profiler-memory-log))
615 t) 610 t)
616 611
617(defun profiler--report-cpu () 612(defun profiler--report-cpu ()
618 (let ((log (profiler-cpu-log))) 613 (let ((log (if (fboundp 'profiler-cpu-log) (profiler-cpu-log))))
619 (when log 614 (when log
620 (puthash 'type 'cpu log) 615 (puthash 'type 'cpu log)
621 (puthash 'timestamp (current-time) log) 616 (puthash 'timestamp (current-time) log)