From 746cd002a4e49d8a0e9ffd305c7e71bc8c90869e Mon Sep 17 00:00:00 2001 From: James Cherti <60946298+jamescherti@users.noreply.github.com> Date: Fri, 7 Mar 2025 09:07:00 -0500 Subject: [PATCH] Update README.md --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README.md b/README.md index a7b7931..a780af9 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,8 @@ The author uses *minimal-emacs.d* as his `early-init.el` and `init.el`, alongsid *(The theme shown in the screenshot above is the *[tomorrow-night-deepblue-theme.el](https://github.com/jamescherti/tomorrow-night-deepblue-theme.el)*, available on MELPA.)* +In addition to *minimal-emacs.d*, startup speed is influenced by your computer's processing power and disk speed. To establish a baseline, start Emacs with only *minimal-emacs.d* and no additional configurations, then run `M-x emacs-init-time`. Incrementally modify your init files and observe the impact on startup time. For consistent comparisons, always test on the same computer and Emacs version. It's also important to ensure that all packages are deferred using `:defer t` and `:commands`, which makes Emacs load them only when needed (see additional examples in this README.md). + ## Table of Contents @@ -53,6 +55,7 @@ The author uses *minimal-emacs.d* as his `early-init.el` and `init.el`, alongsid - [Configuring straight.el?](#configuring-straightel) - [Configuring elpaca (package manager)](#configuring-elpaca-package-manager) - [Frequently asked questions](#frequently-asked-questions) + - [How to display Emacs startup duration?](#how-to-display-emacs-startup-duration) - [How to give more priority to MELPA over MELPA stable?](#how-to-give-more-priority-to-melpa-over-melpa-stable) - [How to load a local lisp file for machine-specific configurations?](#how-to-load-a-local-lisp-file-for-machine-specific-configurations) - [How to load Emacs customizations?](#how-to-load-emacs-customizations) @@ -1061,6 +1064,23 @@ And [add the elpaca bootstrap code](https://github.com/progfolio/elpaca?tab=read ## Frequently asked questions +### How to display Emacs startup duration? + +To measure and display the time taken for Emacs to start, you can use the following Emacs Lisp function. This function will report both the startup duration and the number of garbage collections that occurred during initialization. + +Add the following to your `~/.emacs.d/pre-early-init.el` file: +```emacs-lisp +(defun display-startup-time () + "Display the startup duration and number of garbage collections." + (message "Emacs loaded in %.2f seconds with %d garbage collections." + (time-to-seconds (time-since before-init-time)) + gcs-done)) + +(add-hook 'emacs-startup-hook #'display-startup-time 100) +``` + +(Alternatively, you may use the built-in `M-x emacs-init-time` command to obtain the startup duration.) + ### How to give more priority to MELPA over MELPA stable? **Warning:** MELPA Stable is generally more reliable and thoroughly tested, as it contains stable versions of packages. On the other hand, MELPA provides bleeding-edge versions, which often include new features but may also introduce changes that could potentially break functionality. The author of *minimal-emacs.d* uses MELPA over MELPA Stable without encountering issues, but this is provided as a caution to allow you to make an informed decision based on your stability versus feature needs.