diff options
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'. | |||
| 574 | If MODE is `cpu' or `cpu+mem', time-based profiler will be started. | 574 | If MODE is `cpu' or `cpu+mem', time-based profiler will be started. |
| 575 | Also, if MODE is `mem' or `cpu+mem', then memory profiler will be started." | 575 | Also, 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) |