unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* uptime.el
@ 2007-12-19 10:12 Richard Stallman
  2007-12-19 10:33 ` uptime.el Leo
                   ` (3 more replies)
  0 siblings, 4 replies; 27+ messages in thread
From: Richard Stallman @ 2007-12-19 10:12 UTC (permalink / raw)
  To: emacs-devel

What do people think of this?  (The patch in startup.el should be done
differently.)

Message-ID: <ade856a30712171501q7b6ebb8p8a016058ddd7ab2e@mail.gmail.com>
Date: Tue, 18 Dec 2007 00:01:18 +0100
From: "Francesc Rocher" <francesc.rocher@gmail.com>
To: "Richard M. Stallman" <rms@gnu.org>
Subject: uptime.el
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2)

Hello,

Please consider adding this little piece of elisp code into GNU Emacs:

---8<------
;;; uptime.el --- tell how long Emacs has been up and running

;; Copyright (C) 2007 Free Software Foundation, Inc.

;; Author: Francesc Rocher <rocher@member.fsf.org>
;; Keywords: time, uptime.

;; This file is part of GNU Emacs.

;; GNU Emacs is free software; you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 3, or (at your option)
;; any later version.

;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs; see the file COPYING.  If not, write to the
;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
;; Boston, MA 02110-1301, USA.

;;; Commentary:

;; This file provides a couple of functions: `emacs-uptime' tells you how
;; long Emacs has been up and running. `emacs-startup-time' return a string
;; containing the date and time Emacs was started up.

;;; Code:

(require 'time-date)

;;;###autoload
(defun emacs-uptime (&optional here) "\
Tell how long GNU Emacs has been running.
If the optional argument HERE is non-nil, insert string at point."
  (interactive "P")
  (let* ((days (time-to-number-of-days (time-since emacs-startup-time)))
         (hours (* 24 (- days (truncate days))))
         (minutes (* 60 (- hours (truncate hours))))
         (seconds (* 60 (- minutes (truncate minutes))))
         (uptime-string
          (format "%s,  up %s"
                  (format-time-string "%x %T %Z" (current-time))
                  (format "%s%02d:%02d:%02d"
                          (if (> (truncate days) 0)
                              (format "%d days, " days) "")
                          hours minutes seconds))))
    (if here
        (insert uptime-string)
      (if (interactive-p)
          (message "%s" uptime-string)
        uptime-string))))

;;;###autoload
(defun emacs-startup-time (&optional here format) "\
Return string containing the date and time Emacs was started up.
If the optional argument FORMAT is non-nil, it is used to format
the string. See `format-time-string' for valid formats.
If the optional argument HERE is non-nil, insert string at point."
  (interactive "P")
  (let ((time-string (format-time-string
                      (if (stringp format)
                          format
                        "%x %T %Z")
                      emacs-startup-time)))
    (if here
        (insert time-string)
      (if (interactive-p)
          (message "%s" time-string)
        time-string))))

(provide 'uptime)

;;; arch-tag:
;;; uptime.el ends here
---8<------


Complemented with this constant definition:

diff -u startup.el.~1.470.~ startup.el
--- startup.el.~1.470.~ 2007-12-09 12:08:54.000000000 +0100
+++ startup.el  2007-12-17 23:18:01.000000000 +0100
@@ -2243,5 +2243,9 @@
       (setq file (replace-match "/" t t file)))
     file))

+(eval-at-startup
+ (defconst emacs-startup-time (current-time)
+   "Time at which GNU Emacs was started up."))
+
 ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
 ;;; startup.el ends here




Best regards,
---
Francesc Rocher

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-19 10:12 uptime.el Richard Stallman
@ 2007-12-19 10:33 ` Leo
  2007-12-23  2:26 ` uptime.el Ævar Arnfjörð Bjarmason
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 27+ messages in thread
From: Leo @ 2007-12-19 10:33 UTC (permalink / raw)
  To: emacs-devel

On 2007-12-19 10:12 +0000, Richard Stallman wrote:
> What do people think of this?  (The patch in startup.el should be done
> differently.)

It is useful. For example, "10:30:10 Emacs up 9 day(s), 23:59". I have
put something like the following in .emacs for almost a year.

(defvar emacs-up-time (current-time)
  "Time at which Emacs started up.")
(defun uptime ()
  "Displays Emacs uptime."
  (interactive)
  (let* ((now (current-time))
         (second (floor (- (time-to-seconds now)
                           (time-to-seconds emacs-up-time))))
         (minute (floor second 60))
         (hour (floor minute 60))
         (day (floor hour 24)))
    (message "%s Emacs up %s day(s), %02d:%02d"
             (format-time-string "%T" now) day (% hour 24) (% minute 60))))

-- 
.:  Leo  :.  [ sdl.web AT gmail.com ]  .:  [ GPG Key: 9283AA3F ]  :.

          Use the best OS -- http://www.fedoraproject.org/

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-19 10:12 uptime.el Richard Stallman
  2007-12-19 10:33 ` uptime.el Leo
@ 2007-12-23  2:26 ` Ævar Arnfjörð Bjarmason
  2007-12-23 21:11   ` uptime.el Richard Stallman
  2007-12-23 17:48 ` uptime.el Juri Linkov
  2008-02-11  0:34 ` uptime.el Glenn Morris
  3 siblings, 1 reply; 27+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2007-12-23  2:26 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Richard Stallman <rms@gnu.org> writes:

> What do people think of this?  (The patch in startup.el should be done
> differently.)

Coincidentally I did C-h a uptime RET earlier today and was disappointed
when nothing came up. I think it would be useful to have this as part of
Emacs.

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-19 10:12 uptime.el Richard Stallman
  2007-12-19 10:33 ` uptime.el Leo
  2007-12-23  2:26 ` uptime.el Ævar Arnfjörð Bjarmason
@ 2007-12-23 17:48 ` Juri Linkov
  2007-12-24 13:31   ` uptime.el Richard Stallman
  2008-02-11  0:34 ` uptime.el Glenn Morris
  3 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2007-12-23 17:48 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

> What do people think of this?  (The patch in startup.el should be done
> differently.)

This looks like a good fit to time.el with `display-uptime', no?

> Message-ID: <ade856a30712171501q7b6ebb8p8a016058ddd7ab2e@mail.gmail.com>
> Date: Tue, 18 Dec 2007 00:01:18 +0100
> From: "Francesc Rocher" <francesc.rocher@gmail.com>
> To: "Richard M. Stallman" <rms@gnu.org>
> Subject: uptime.el
> MIME-Version: 1.0
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 7bit
> Content-Disposition: inline
> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2)
>
> Hello,
>
> Please consider adding this little piece of elisp code into GNU Emacs:
>
> ---8<------
> ;;; uptime.el --- tell how long Emacs has been up and running
>
> ;; Copyright (C) 2007 Free Software Foundation, Inc.
>
> ;; Author: Francesc Rocher <rocher@member.fsf.org>
> ;; Keywords: time, uptime.
>
> ;; This file is part of GNU Emacs.
>
> ;; GNU Emacs is free software; you can redistribute it and/or modify
> ;; it under the terms of the GNU General Public License as published by
> ;; the Free Software Foundation; either version 3, or (at your option)
> ;; any later version.
>
> ;; GNU Emacs is distributed in the hope that it will be useful,
> ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
> ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> ;; GNU General Public License for more details.
>
> ;; You should have received a copy of the GNU General Public License
> ;; along with GNU Emacs; see the file COPYING.  If not, write to the
> ;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
> ;; Boston, MA 02110-1301, USA.
>
> ;;; Commentary:
>
> ;; This file provides a couple of functions: `emacs-uptime' tells you how
> ;; long Emacs has been up and running. `emacs-startup-time' return a string
> ;; containing the date and time Emacs was started up.
>
> ;;; Code:
>
> (require 'time-date)
>
> ;;;###autoload
> (defun emacs-uptime (&optional here) "\
> Tell how long GNU Emacs has been running.
> If the optional argument HERE is non-nil, insert string at point."
>   (interactive "P")
>   (let* ((days (time-to-number-of-days (time-since emacs-startup-time)))
>          (hours (* 24 (- days (truncate days))))
>          (minutes (* 60 (- hours (truncate hours))))
>          (seconds (* 60 (- minutes (truncate minutes))))
>          (uptime-string
>           (format "%s,  up %s"
>                   (format-time-string "%x %T %Z" (current-time))
>                   (format "%s%02d:%02d:%02d"
>                           (if (> (truncate days) 0)
>                               (format "%d days, " days) "")
>                           hours minutes seconds))))
>     (if here
>         (insert uptime-string)
>       (if (interactive-p)
>           (message "%s" uptime-string)
>         uptime-string))))
>
> ;;;###autoload
> (defun emacs-startup-time (&optional here format) "\
> Return string containing the date and time Emacs was started up.
> If the optional argument FORMAT is non-nil, it is used to format
> the string. See `format-time-string' for valid formats.
> If the optional argument HERE is non-nil, insert string at point."
>   (interactive "P")
>   (let ((time-string (format-time-string
>                       (if (stringp format)
>                           format
>                         "%x %T %Z")
>                       emacs-startup-time)))
>     (if here
>         (insert time-string)
>       (if (interactive-p)
>           (message "%s" time-string)
>         time-string))))
>
> (provide 'uptime)
>
> ;;; arch-tag:
> ;;; uptime.el ends here
> ---8<------
>
>
> Complemented with this constant definition:
>
> diff -u startup.el.~1.470.~ startup.el
> --- startup.el.~1.470.~ 2007-12-09 12:08:54.000000000 +0100
> +++ startup.el  2007-12-17 23:18:01.000000000 +0100
> @@ -2243,5 +2243,9 @@
>        (setq file (replace-match "/" t t file)))
>      file))
>
> +(eval-at-startup
> + (defconst emacs-startup-time (current-time)
> +   "Time at which GNU Emacs was started up."))
> +
>  ;; arch-tag: 7e294698-244d-4758-984b-4047f887a5db
>  ;;; startup.el ends here

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-23  2:26 ` uptime.el Ævar Arnfjörð Bjarmason
@ 2007-12-23 21:11   ` Richard Stallman
  0 siblings, 0 replies; 27+ messages in thread
From: Richard Stallman @ 2007-12-23 21:11 UTC (permalink / raw)
  To: Ævar Arnfjörð Bjarmason; +Cc: emacs-devel

What about the code in uptime.el.  Does anyone else see a reason
to change it before installation?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-23 17:48 ` uptime.el Juri Linkov
@ 2007-12-24 13:31   ` Richard Stallman
  2007-12-24 21:59     ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Richard Stallman @ 2007-12-24 13:31 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

    This looks like a good fit to time.el with `display-uptime', no?

If you are suggesting a change, could you be more precise?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-24 13:31   ` uptime.el Richard Stallman
@ 2007-12-24 21:59     ` Juri Linkov
  2007-12-25 21:13       ` uptime.el Richard Stallman
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2007-12-24 21:59 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

>     This looks like a good fit to time.el with `display-uptime', no?
>
> If you are suggesting a change, could you be more precise?

This was just a hint.  If this is not useful, let's install this code as is.

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

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-24 21:59     ` uptime.el Juri Linkov
@ 2007-12-25 21:13       ` Richard Stallman
  0 siblings, 0 replies; 27+ messages in thread
From: Richard Stallman @ 2007-12-25 21:13 UTC (permalink / raw)
  To: Juri Linkov; +Cc: emacs-devel

    >     This looks like a good fit to time.el with `display-uptime', no?
    >
    > If you are suggesting a change, could you be more precise?

    This was just a hint.  If this is not useful, let's install this code as is.

The idea you are hinting at might be a good idea,
but I am not sure what idea it is.  Could you say it explicitly?

^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2007-12-19 10:12 uptime.el Richard Stallman
                   ` (2 preceding siblings ...)
  2007-12-23 17:48 ` uptime.el Juri Linkov
@ 2008-02-11  0:34 ` Glenn Morris
  2008-02-12  0:14   ` uptime.el Juri Linkov
  3 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-11  0:34 UTC (permalink / raw)
  To: rms; +Cc: emacs-devel

Richard Stallman wrote:

> What do people think of this? 

Might as well have this functionality. I installed something similar.

> (The patch in startup.el should be done differently.)

I set emacs-startup-time in command-line.

> (defun emacs-uptime (&optional here) "\
> Tell how long GNU Emacs has been running.
> If the optional argument HERE is non-nil, insert string at point."

Didn't see the point of the HERE argument; used an alternative
implementation based on something in gnus-art.

> (defun emacs-startup-time (&optional here format) "\
> Return string containing the date and time Emacs was started up.

Didn't see the point of this function, which is basically just a call
to format-time-string.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
@ 2008-02-11 23:03 Francesc Rocher
  2008-02-12  5:54 ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Francesc Rocher @ 2008-02-11 23:03 UTC (permalink / raw)
  To: emacs-devel

>Glenn Morris wrote:
>
>Might as well have this functionality. I installed something similar.
>
>I set emacs-startup-time in command-line.

I prefer `emacs-startup-time' defined as a constant, not as a variable. As
such, it needs to be evaluated only at startup:

   (eval-at-startup
    (defconst emacs-startup-time (current-time)
      "Time at which GNU Emacs was started up."))


>> (defun emacs-uptime (&optional here) "\
>> Tell how long GNU Emacs has been running.
>> If the optional argument HERE is non-nil, insert string at point."
>
>Didn't see the point of the HERE argument; used an alternative
>implementation based on something in gnus-art.

The HERE argument is the same as of the function `emacs-version'.


>> (defun emacs-startup-time (&optional here format) "\
>> Return string containing the date and time Emacs was started up.
>
>Didn't see the point of this function, which is basically just a call
>to format-time-string.

`emacs-uptime' tells you how long emacs has been running, whilst
`emacs-startup-time' tells you the time at which Emacs was started up.


Regards,
---
Francesc Rocher




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-11  0:34 ` uptime.el Glenn Morris
@ 2008-02-12  0:14   ` Juri Linkov
  2008-02-12  5:50     ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-12  0:14 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rms, emacs-devel

>> What do people think of this?
>
> Might as well have this functionality. I installed something similar.

Thanks.

>> (The patch in startup.el should be done differently.)
>
> I set emacs-startup-time in command-line.

I think there should be two recorded startup timestamps instead of one:
the first timestamp recorded as early as possible, and the second - when
Emacs completely finishes loading .emacs and all related files.

The difference between these two timestamps will show how much time the
startup process itself takes.  This is useful for optimization of
.emacs loading.

So a new command emacs-startup-time could display (or non-interactively
return) the duration of the Emacs startup.

>> (defun emacs-uptime (&optional here) "\
>> Tell how long GNU Emacs has been running.
>> If the optional argument HERE is non-nil, insert string at point."
>
> Didn't see the point of the HERE argument; used an alternative
> implementation based on something in gnus-art.

A general time difference function would be definitely useful,
but what format it should use?  For the uptime perhaps the standard
format of the `uptime' system command is more preferable, e.g.
"15:16:19 up 51 days 1 year".

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-12  0:14   ` uptime.el Juri Linkov
@ 2008-02-12  5:50     ` Glenn Morris
  0 siblings, 0 replies; 27+ messages in thread
From: Glenn Morris @ 2008-02-12  5:50 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rms, emacs-devel

Juri Linkov wrote:

> A general time difference function would be definitely useful, but
> what format it should use? For the uptime perhaps the standard
> format of the `uptime' system command is more preferable, e.g.
> "15:16:19 up 51 days 1 year".

Personally I think the `uptime' format ("up 3 days,  6:41") is ugly.

I mean something where you can specify a format-string. I have in mind
something like:

(defun format-seconds (format-string seconds)
  "Use FORMAT-STRING to format the number SECONDS.
The valid format specifiers are:
%y is the number of (365-day) years.
%d is the number of days.
%h is the number of hours.
%m is the number of minutes.
%s is the number of seconds.

Upper-case specifiers are followed by the unit-name (e.g. \"years\").
Lower-case specifiers return only the unit."

together with the ability to say eg "%.3y" for 001 years.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-11 23:03 uptime.el Francesc Rocher
@ 2008-02-12  5:54 ` Glenn Morris
  2008-02-12 23:35   ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-12  5:54 UTC (permalink / raw)
  To: Francesc Rocher; +Cc: emacs-devel

"Francesc Rocher" wrote:

>>I set emacs-startup-time in command-line.
>
> I prefer `emacs-startup-time' defined as a constant, not as a variable. As
> such, it needs to be evaluated only at startup:
>
>    (eval-at-startup
>     (defconst emacs-startup-time (current-time)
>       "Time at which GNU Emacs was started up."))

That just adds something to before-init-hook, which is run by command-line. 

> The HERE argument is the same as of the function `emacs-version'.

I don't see the point of the HERE argument there either. :)
Should every function that returns a string optionally insert it?

> `emacs-uptime' tells you how long emacs has been running, whilst
> `emacs-startup-time' tells you the time at which Emacs was started up.

I'm saying I don't see the need for a specialized function that
essentially just calls format-time-string on emacs-startup-time. If
someone wants to add it, they should go ahead.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-12  5:54 ` uptime.el Glenn Morris
@ 2008-02-12 23:35   ` Juri Linkov
  2008-02-14  9:04     ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-12 23:35 UTC (permalink / raw)
  To: Glenn Morris; +Cc: Francesc Rocher, emacs-devel

>> The HERE argument is the same as of the function `emacs-version'.
>
> I don't see the point of the HERE argument there either. :)
> Should every function that returns a string optionally insert it?

The HERE argument of `emacs-version' is very useful to insert
the Emacs version string to the current buffer (to mail, etc.)

>> `emacs-uptime' tells you how long emacs has been running, whilst
>> `emacs-startup-time' tells you the time at which Emacs was started up.
>
> I'm saying I don't see the need for a specialized function that
> essentially just calls format-time-string on emacs-startup-time. If
> someone wants to add it, they should go ahead.

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.

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-12 23:35   ` uptime.el Juri Linkov
@ 2008-02-14  9:04     ` Glenn Morris
  2008-02-14 20:56       ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-14  9:04 UTC (permalink / raw)
  To: Juri Linkov; +Cc: Francesc Rocher, emacs-devel

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.  I checked in a version of `format-seconds', by the way.





^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-14  9:04     ` uptime.el Glenn Morris
@ 2008-02-14 20:56       ` Juri Linkov
  2008-02-15  8:02         ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-14 20:56 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rocher, emacs-devel

> 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/




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-14 20:56       ` uptime.el Juri Linkov
@ 2008-02-15  8:02         ` Glenn Morris
  2008-02-16  0:27           ` uptime.el Juri Linkov
  2008-02-16  2:00           ` uptime.el Xavier Maillard
  0 siblings, 2 replies; 27+ messages in thread
From: Glenn Morris @ 2008-02-15  8:02 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rocher, emacs-devel

Juri Linkov wrote:

> + (defvar emacs-startup-time-after-init nil

emacs-after-init-time?
emacs-init-end-time?

> + (defun emacs-startup-time ()
> +   "Return a string giving the Emacs startup time."

This might be confused with the time at which Emacs started.
emacs-init-duration?

> +   (interactive)
> +   (let ((str
> +          (format-seconds "Startup time: %Y, %D, %H, %M, %S"

Hopefully emacs won't take an hour, or even many minutes to start, so
you can probably just return the number of seconds without formatting it.

I guess I had some opinions after all. :)




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-15  8:02         ` uptime.el Glenn Morris
@ 2008-02-16  0:27           ` Juri Linkov
  2008-02-16  3:35             ` uptime.el Glenn Morris
  2008-02-16  2:00           ` uptime.el Xavier Maillard
  1 sibling, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-16  0:27 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rocher, emacs-devel

>> + (defvar emacs-startup-time-after-init nil
>
> emacs-after-init-time?
> emacs-init-end-time?
>
>> + (defun emacs-startup-time ()
>> +   "Return a string giving the Emacs startup time."
>
> This might be confused with the time at which Emacs started.
> emacs-init-duration?

Maybe emacs-init-time (for both the variable and command names
to reduce confusion).

>> +   (interactive)
>> +   (let ((str
>> +          (format-seconds "Startup time: %Y, %D, %H, %M, %S"
>
> Hopefully emacs won't take an hour, or even many minutes to start, so
> you can probably just return the number of seconds without formatting it.

But do you expect an instance of Emacs to run years (as can be reported
by emacs-uptime :)?

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-15  8:02         ` uptime.el Glenn Morris
  2008-02-16  0:27           ` uptime.el Juri Linkov
@ 2008-02-16  2:00           ` Xavier Maillard
  1 sibling, 0 replies; 27+ messages in thread
From: Xavier Maillard @ 2008-02-16  2:00 UTC (permalink / raw)
  To: Glenn Morris; +Cc: juri, rocher, emacs-devel

   > +          (format-seconds "Startup time: %Y, %D, %H, %M, %S"

   Hopefully emacs won't take an hour, or even many minutes to start, so
   you can probably just return the number of seconds without formatting it.

The number of seconds from what ? :) I think it could be
interesting to know precisely when GNU Emacs started up. Maybe I
misunderstood something here.

	Xavier
-- 
http://www.gnu.org
http://www.april.org
http://www.lolica.org




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-16  0:27           ` uptime.el Juri Linkov
@ 2008-02-16  3:35             ` Glenn Morris
  2008-02-16 19:14               ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-16  3:35 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rocher, emacs-devel

Juri Linkov wrote:

> Maybe emacs-init-time (for both the variable and command names
> to reduce confusion).

I was actually thinking it might be good to rename emacs-startup-time
to before-init-time, and add after-init-time (consistent with
before-init-hook etc). I think it would be confusing for -time to mean
both a time and an interval.

> But do you expect an instance of Emacs to run years (as can be reported
> by emacs-uptime :)?

Why not? That was a deliberate piece of optimism! :)




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-16  3:35             ` uptime.el Glenn Morris
@ 2008-02-16 19:14               ` Juri Linkov
  2008-02-16 22:22                 ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-16 19:14 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rocher, emacs-devel

>> Maybe emacs-init-time (for both the variable and command names
>> to reduce confusion).
>
> I was actually thinking it might be good to rename emacs-startup-time
> to before-init-time, and add after-init-time (consistent with
> before-init-hook etc). I think it would be confusing for -time to mean
> both a time and an interval.

I agree that before-init-time and after-init-time are better for
consistency, and I also think that emacs-init-time would be consistent
with emacs-uptime regardless of the distinction between a time and
an interval.

>> But do you expect an instance of Emacs to run years (as can be reported
>> by emacs-uptime :)?
>
> Why not? That was a deliberate piece of optimism! :)

So there is the difference: optimism is to expect years in the Emacs
running time but pessimism is to expect the same in the Emacs startup
duration :)

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-16 19:14               ` uptime.el Juri Linkov
@ 2008-02-16 22:22                 ` Glenn Morris
  2008-02-16 23:18                   ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-16 22:22 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rocher, emacs-devel

Juri Linkov wrote:

> I agree that before-init-time and after-init-time are better for
> consistency,

I changed emacs-startup-time to before-init-time.

> and I also think that emacs-init-time would be consistent with
> emacs-uptime regardless of the distinction between a time and an
> interval.

Sounds good to me. Please install.




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-16 22:22                 ` uptime.el Glenn Morris
@ 2008-02-16 23:18                   ` Juri Linkov
  2008-02-17  0:19                     ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-16 23:18 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rocher, emacs-devel

>> I agree that before-init-time and after-init-time are better for
>> consistency,
>
> I changed emacs-startup-time to before-init-time.
>
>> and I also think that emacs-init-time would be consistent with
>> emacs-uptime regardless of the distinction between a time and an
>> interval.
>
> Sounds good to me. Please install.

Installed.

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-16 23:18                   ` uptime.el Juri Linkov
@ 2008-02-17  0:19                     ` Glenn Morris
  2008-02-17  0:45                       ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-17  0:19 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rocher, emacs-devel

Juri Linkov wrote:

> Installed.

I think the call to format-seconds in emacs-init-time is pointless,
and it's going to integerize the seconds. I'd just use
(format "%.1f seconds" ...)




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-17  0:19                     ` uptime.el Glenn Morris
@ 2008-02-17  0:45                       ` Juri Linkov
  2008-02-17 22:55                         ` uptime.el Glenn Morris
  0 siblings, 1 reply; 27+ messages in thread
From: Juri Linkov @ 2008-02-17  0:45 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rocher, emacs-devel

> I think the call to format-seconds in emacs-init-time is pointless,
> and it's going to integerize the seconds. I'd just use
> (format "%.1f seconds" ...)

I agree, maybe even without the fractional part as "%.0f seconds".

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-17  0:45                       ` uptime.el Juri Linkov
@ 2008-02-17 22:55                         ` Glenn Morris
  2008-02-17 23:11                           ` uptime.el Juri Linkov
  0 siblings, 1 reply; 27+ messages in thread
From: Glenn Morris @ 2008-02-17 22:55 UTC (permalink / raw)
  To: Juri Linkov; +Cc: rocher, emacs-devel

Juri Linkov wrote:

>> (format "%.1f seconds" ...)
>
> I agree, maybe even without the fractional part as "%.0f seconds".

I'd have thought that the kind of people interested in knowing how
long their Emacs takes to start would be the kind interested in
fractions of a second. :)




^ permalink raw reply	[flat|nested] 27+ messages in thread

* Re: uptime.el
  2008-02-17 22:55                         ` uptime.el Glenn Morris
@ 2008-02-17 23:11                           ` Juri Linkov
  0 siblings, 0 replies; 27+ messages in thread
From: Juri Linkov @ 2008-02-17 23:11 UTC (permalink / raw)
  To: Glenn Morris; +Cc: rocher, emacs-devel

>> I agree, maybe even without the fractional part as "%.0f seconds".
>
> I'd have thought that the kind of people interested in knowing how
> long their Emacs takes to start would be the kind interested in
> fractions of a second. :)

OK, fixed.

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




^ permalink raw reply	[flat|nested] 27+ messages in thread

end of thread, other threads:[~2008-02-17 23:11 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-02-11 23:03 uptime.el Francesc Rocher
2008-02-12  5:54 ` uptime.el Glenn Morris
2008-02-12 23:35   ` uptime.el Juri Linkov
2008-02-14  9:04     ` uptime.el Glenn Morris
2008-02-14 20:56       ` uptime.el Juri Linkov
2008-02-15  8:02         ` uptime.el Glenn Morris
2008-02-16  0:27           ` uptime.el Juri Linkov
2008-02-16  3:35             ` uptime.el Glenn Morris
2008-02-16 19:14               ` uptime.el Juri Linkov
2008-02-16 22:22                 ` uptime.el Glenn Morris
2008-02-16 23:18                   ` uptime.el Juri Linkov
2008-02-17  0:19                     ` uptime.el Glenn Morris
2008-02-17  0:45                       ` uptime.el Juri Linkov
2008-02-17 22:55                         ` uptime.el Glenn Morris
2008-02-17 23:11                           ` uptime.el Juri Linkov
2008-02-16  2:00           ` uptime.el Xavier Maillard
  -- strict thread matches above, loose matches on Subject: below --
2007-12-19 10:12 uptime.el Richard Stallman
2007-12-19 10:33 ` uptime.el Leo
2007-12-23  2:26 ` uptime.el Ævar Arnfjörð Bjarmason
2007-12-23 21:11   ` uptime.el Richard Stallman
2007-12-23 17:48 ` uptime.el Juri Linkov
2007-12-24 13:31   ` uptime.el Richard Stallman
2007-12-24 21:59     ` uptime.el Juri Linkov
2007-12-25 21:13       ` uptime.el Richard Stallman
2008-02-11  0:34 ` uptime.el Glenn Morris
2008-02-12  0:14   ` uptime.el Juri Linkov
2008-02-12  5:50     ` uptime.el Glenn Morris

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).