Emacs Asked on December 7, 2021
Currently when making changes to the mode-line, I try to write efficient elisp,
However I don’t know for sure if what I’m doing is in fact efficient.
How could I test the mode-line performance?
For example – redraw the mode-line in a loop and time that.
This interactive function times format-mode-line
.
(defmacro mode-line-benchmark-elapse-time (&rest forms)
"Return the time in seconds elapsed for execution of FORMS."
(declare (indent 0) (debug t))
(let ((t1 (make-symbol "t1")))
`
(let (,t1)
(setq ,t1 (current-time))
,@forms
(float-time (time-since ,t1)))))
(defun mode-line-benchmark ()
(interactive)
(let* ((value nil)
(repetitions 10000)
(wall-clock-time
(mode-line-benchmark-elapse-time
(dotimes (_ repetitions)
(setq value (format-mode-line mode-line-format)))))
(average-time (/ wall-clock-time repetitions)))
(message
"Time: %.10f per call, %.10f for %S calls: %S"
average-time wall-clock-time repetitions value)))
This can be run manually with M-x mode-line-benchmark
Answered by ideasman42 on December 7, 2021
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP