Skip to content

Commit

Permalink
Add benchmark-init and write its results to a CSV file
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffkreeftmeijer committed May 3, 2024
1 parent 92483a1 commit 1355183
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
13 changes: 13 additions & 0 deletions default.el
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
;;; -*- lexical-binding: t -*-

(use-package benchmark-init
:ensure t
:config
(add-hook 'after-init-hook 'benchmark-init/deactivate))

(require 'bind-key)

(use-package frame
Expand Down Expand Up @@ -266,3 +271,11 @@ end tell"))
(use-package pixel-scroll
:init
(pixel-scroll-precision-mode 1))

(write-region
(format "%s,%s\n"
(string-trim (shell-command-to-string "git --git-dir ~/emacs-config/.git rev-parse HEAD"))
(benchmark-init/node-duration-adjusted benchmark-init/durations-tree))
nil
"~/.emacs.d/benchmark.csv"
'append)
32 changes: 32 additions & 0 deletions emacs-configuration.org
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@

#+headers: :exports none
#+headers: :tangle default.el
#+headers: :noweb yes
#+begin_src emacs-lisp
;;; -*- lexical-binding: t -*-

<<benchmark-init>>

(require 'bind-key)
#+end_src

Expand Down Expand Up @@ -1708,3 +1711,32 @@ Project-x should be obsolete for this purpose, but I haven't figured it out yet.
:init
<<pixel-scroll-init>>)
#+end_src

* Benchmarking

Use [[https://github.com/dholm/benchmark-init-el][benchmark-init]] to benchmark Emacs' initialization.
Enable benchmark-init at the top of the configuration file, before any packages are loaded.

#+name: benchmark-init
#+begin_src emacs-lisp
(use-package benchmark-init
:ensure t
:config
(add-hook 'after-init-hook 'benchmark-init/deactivate))
#+end_src

After starting Emacs, the benchmarking results can be examined using the ~benchmark-init/show-durations-tree~ function.
Aside from that, append the total duration to a file named =~/.emacs.d/benchmark.csv= for future reference.

#+headers: :tangle default.el
#+begin_src emacs-lisp
(write-region
(format "%s,%s\n"
(string-trim (shell-command-to-string "git --git-dir ~/emacs-config/.git rev-parse HEAD"))
(benchmark-init/node-duration-adjusted benchmark-init/durations-tree))
nil
"~/.emacs.d/benchmark.csv"
'append)
#+end_src

#+RESULTS:

0 comments on commit 1355183

Please sign in to comment.