emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [O] How to improve Org startup time?


From: Sebastien Vauban
Subject: Re: [O] How to improve Org startup time?
Date: Thu, 31 Jan 2013 13:30:01 +0100
User-agent: Gnus/5.130006 (Ma Gnus v0.6) Emacs/24.2.92 (windows-nt)

Hi Eric,

Eric S Fraga wrote:
> Sebastien Vauban <address@hidden> writes:
>> Please find here an enriched log of the packages which are loaded for Org, 
>> and
>> the time it takes.
>>
>> [2013-01-29 21:20:18] (info) +-> Requiring `appt'...
>> [2013-01-29 21:20:18] (info)   +-> Requiring `diary-lib'...
>> [2013-01-29 21:20:18] (info)     +-> Requiring `calendar'...
>
> how do you get this output?  It looks very useful!

The timestamp stuff comes from EmacsWiki:

#+begin_src emacs-lisp
  (defadvice message (before when-was-that activate)
    "Add timestamps to `message' output."
    (ad-set-arg 0 (concat (format-time-string "[%Y-%m-%d %T] ")
                          (ad-get-arg 0))))
#+end_src

The "call tree" between packages is originally written by me:

#+begin_src emacs-lisp
  (defadvice require (around require-around activate)
    "Leave a trace of packages being loaded."
    (let* ((feature (ad-get-arg 0))
           (require-depth (or (and (boundp 'require-depth) require-depth)
                              0))
           (prefix (concat (make-string (* 2 require-depth) ? ) "+-> ")))
      (cond ((featurep feature)
             (message "(info) %sRequiring `%s'... already loaded"
                      prefix feature)
             ;; in the case `ad-do-it' is not called, you have to set the
             ;; return value yourself!
             (setq ad-return-value feature))
            (t
             (let ((lvn/time-start))
               (message "(info) %sRequiring `%s'..." prefix feature)
               (setq lvn/time-start (float-time))
               (let ((require-depth (1+ require-depth)))
                 ad-do-it)
               (message "(info) %sRequiring `%s'... %s (loaded in %.2f s)"
                        prefix feature
                        (locate-library (symbol-name feature))
                        (- (float-time) lvn/time-start)))))))
#+end_src

You can further improve what you see in the echo area with:

#+begin_src emacs-lisp
  (defadvice load (before debug-log activate)
    (message "(info) Loading %s..." (locate-library (ad-get-arg 0))))

  (defadvice load-library (before debug-log activate)
    (message "(info) Loading library `%s'..." (locate-library (ad-get-arg 0))))

  (defadvice load-file (before debug-log activate)
    (message "(info) Loading file `%s'..." (locate-library (ad-get-arg 0))))

  (defadvice find-file (around find-file-around activate)
    "Open FILENAME and report time spent."
    (let ((filename (ad-get-arg 0))
          (find-file-time-start (float-time)))
      (message "(info) Finding file %s..." filename)
      ad-do-it
      (message "(info) Found file %s in %.2f s." filename
               (- (float-time) find-file-time-start))))
#+end_src

Adapt it to your taste (and report it!)...

> In terms of the actual topic of this thread, I can say that the recent
> changes to org for startup have led to a significant decrease in my
> emacs startup time.  Thanks to all that have done this!

I hope to benefit from all that soon, as well...

Best regards,
  Seb

-- 
Sebastien Vauban




reply via email to

[Prev in Thread] Current Thread [Next in Thread]