emacs-devel
[Top][All Lists]
Advanced

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

Re: uptime.el


From: Juri Linkov
Subject: Re: uptime.el
Date: Thu, 14 Feb 2008 22:56:59 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.60 (gnu/linux)

> Juri Linkov wrote:
>
>> Maybe `emacs-uptime' should display (and insert) both how long emacs
>> has been running and the time when it was started up.
>>
>> As for `emacs-startup-time', I think it would be useful if it displayed
>> how long the startup itself takes.
>
> I don't have much of an opinion. Feel free to make whatever changes
> you like.

Like below.  I think the second time should be recorded just before running
`after-init-hook' to allow users putting in .emacs:

(add-hook 'after-init-hook (lambda () (message "%s" (emacs-startup-time))) t)

Index: lisp/startup.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/startup.el,v
retrieving revision 1.477
diff -c -r1.477 startup.el
*** lisp/startup.el     12 Feb 2008 23:41:08 -0000      1.477
--- lisp/startup.el     14 Feb 2008 20:55:10 -0000
***************
*** 197,202 ****
--- 197,205 ----
  (defvar emacs-startup-time nil
    "Value of `current-time' when Emacs was started.")
  
+ (defvar emacs-startup-time-after-init nil
+   "Value of `current-time' after loading init files.")
+ 
  (defvar emacs-startup-hook nil
    "Normal hook run after loading init files and handling the command line.")
  
***************
*** 1097,1102 ****
--- 1100,1107 ----
                 (eq face-ignored-fonts old-face-ignored-fonts))
        (clear-face-cache)))
  
+   (setq emacs-startup-time-after-init (current-time))
+ 
    (run-hooks 'after-init-hook)
  
    ;; Decode all default-directory.

Index: lisp/time.el
===================================================================
RCS file: /sources/emacs/emacs/lisp/time.el,v
retrieving revision 1.101
diff -c -r1.101 time.el
*** lisp/time.el        8 Jan 2008 20:44:42 -0000       1.101
--- lisp/time.el        14 Feb 2008 20:54:51 -0000
***************
*** 548,553 ****
--- 548,567 ----
            (when (equal (symbol-name (aref elt 5)) "display-time-world-timer")
              (cancel-timer elt)))))))
  
+ ;;;###autoload
+ (defun emacs-startup-time ()
+   "Return a string giving the Emacs startup time."
+   (interactive)
+   (let ((str
+          (format-seconds "Startup time: %Y, %D, %H, %M, %S"
+                          (time-to-seconds
+                           (time-subtract emacs-startup-time-after-init
+                                        emacs-startup-time))
+                          t)))
+     (if (interactive-p)
+         (message "%s" str)
+       str)))
+ 
  (provide 'time)
  
  ;;; arch-tag: b9c1623f-b5cb-48e4-b650-482a4d23c5a6

-- 
Juri Linkov
http://www.jurta.org/emacs/




reply via email to

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