Use benchmark-init to find out where Emacs is spending time during startup.

Most of the links in this page were dead last time I checked. Here are more recent references.

It all boils down to:

Here is an article I wrote about optimizing Emacs startup times. Rather than posting the whole text of the article, I will just give the link to my site (feel free to edit and post the text here if you feel that would be more approriate):


– kruhft

The Blog does not exist any more (as checked on 16th September 2010). Does anyone have the text of the entry?


Part of the instructions posted involve trying to determine library dependencies by hand in an iterative fashion (add a library, try again, check the error messages, add a library, try again…).

You can use library Lisp:lib-requires.el to facilitate this task of determining library dependencies. See LibraryDependencies#LibRequires. – DrewAdams

Here is a function to do some of the manual work that I outlined in my article. It parses the Messages buffer looking for ‘Loading [file]…’ lines, and then prints the lines that need to be inserted into loadup.el to preload those elisp files into the main emacs binary.

(defun loadup-gen ()
  "Generate the lines to include in the lisp/loadup.el file
to place all of the libraries that are loaded by your InitFile
into the main dumped emacs"
  (defun get-loads-from-*Messages* ()
      (let ((retval ()))
	(set-buffer "*Messages*")
	(while (search-forward-regexp "^Loading " nil t)
	  (let ((start (point)))
	    (search-forward "...")
	    (backward-char 3)
	    (setq retval (cons (buffer-substring-no-properties start (point)) retval))))
  (map 'list
       (lambda (file) (princ (format "(load \"%s\")\n" file)))

Optimizing emacs startup on another front: i wrote a library that helps optimize the startup times of your InitFile: http://www.gnufans.net/~deego/pub/emacspub/lisp-mine/dope/ — deego

Here’s a bit of code i use to time my .emacs:

;; time the loading of the .emacs
;; keep this on top of your .emacs
(defvar *emacs-load-start* (current-time))
(defun anarcat/time-to-ms (time)
  (+ (* (+ (* (car time) (expt 2 16)) (car (cdr time))) 1000000) (car (cdr (cdr time)))))
(defun anarcat/display-timing ()
  (message ".emacs loaded in %fms" (/ (- (anarcat/time-to-ms (current-time)) (anarcat/time-to-ms *emacs-load-start*)) 1000000.0)))
(add-hook 'after-init-hook 'anarcat/display-timing t)

.. modified from http://a-nickels-worth.blogspot.com/2007/11/effective-emacs.html. – TheAnarcat

Emacs already comes with ‘M-x emacs-init-time’.