-
-
Notifications
You must be signed in to change notification settings - Fork 113
elisp profiling
Adam Spiers edited this page Jun 30, 2020
·
3 revisions
The following hydra allows easy use of emacs' built-in profiler.el
for profiling the performance of elisp. Note that it depends on the excellent magnars/s.el and magnars/s.el libraries, which you probably already have installed because so many other packages also depend on them.
Instead of the version below, you may prefer to use the version at https://github.com/aspiers/emacs/blob/master/.emacs.d/init.d/as-profiling.el for any of the following reasons:
- It may be updated more regularly than this wiki page. (PRs are welcome!)
- It is conveniently wrapped in a
use-package
sexp. - It adds a
.
binding toprofiler-report-mode-map
for conveniently stopping the profiler while viewing a report.
(defun profiler-running-modes ()
(let ((running-modes
(-non-nil (list (if (profiler-cpu-running-p) "cpu")
(if (profiler-memory-running-p) "mem")))))
(if running-modes
(s-join "+" running-modes)
"stopped")))
(defhydra hydra-profiler
(:color red)
"
elisp profiling (currently %s(profiler-running-modes))
"
("s" profiler-start "start (prompt for mode)" :column "Start / stop")
("c" (profiler-start 'cpu) "start CPU profiling")
("m" (profiler-start 'mem) "start memory profiling")
("b" (profiler-start 'cpu+mem) "start both CPU+memory profiling")
("." profiler-stop "stop")
("R" profiler-reset "Reset")
("q" nil "Cancel")
("r" profiler-report "report" :column "Reporting" :color blue)
("f" profiler-find-profile "find profile")
("4" profiler-find-profile-other-window "find profile other window")
("5" profiler-find-profile-other-frame "find profile other frame"))
- Binding-Styles
- Basics
- Verbosity
- Conditional-Hydra
- defcustom
- Hydra-Colors
- internals
- Nesting-Hydras
- Prefix-map