[Emacs] Add startup time and uptime logging for Emacs

This commit is contained in:
Lucien Cartier-Tilet 2021-10-20 16:03:31 +02:00
parent 4c7b7f9580
commit 3134667967
Signed by: phundrak
GPG Key ID: BD7789E705CB8DCA
1 changed files with 22 additions and 0 deletions

View File

@ -249,6 +249,28 @@ files by default.
auto-save-default t)
#+end_src
Im also interested in keeping track of how fast Emacs loads on my
computer, as well as for how long I keep it open. The values are
stored in a ~.csv~ with three columns:
- The date when Emacs was closed
- Emacs init time
- Emacs uptime
#+begin_src emacs-lisp
(defvar my/emacs-log-file-time (expand-file-name "emacs-time.csv" user-emacs-directory))
(defun my/write-emacs-loadtime-and-uptime ()
(with-temp-buffer
(find-file my/emacs-log-file-time)
(goto-char (point-max))
(insert (format "%s,%s,%s\n"
(string-trim (shell-command-to-string "date +%F-%H-%M-%S"))
(emacs-init-time "%f")
(emacs-uptime "%dd %hh %mm %ss")))
(save-buffer)))
(add-to-list 'kill-emacs-hook #'my/write-emacs-loadtime-and-uptime)
#+end_src
#+begin_src emacs-lisp
(setq window-combination-resize t) ; take new window space from all other windows
#+end_src