GNU bug report logs - #65251
30.0.50; Duration in compilation buffer

Previous Next

Package: emacs;

Reported by: Helmut Eller <eller.helmut <at> gmail.com>

Date: Sat, 12 Aug 2023 18:32:02 UTC

Severity: normal

Found in version 30.0.50

Done: Eli Zaretskii <eliz <at> gnu.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: help-debbugs <at> gnu.org (GNU bug Tracking System)
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: tracker <at> debbugs.gnu.org
Subject: bug#65251: closed (30.0.50; Duration in compilation buffer)
Date: Sat, 19 Aug 2023 05:55:02 +0000
[Message part 1 (text/plain, inline)]
Your message dated Sat, 19 Aug 2023 08:54:40 +0300
with message-id <83il9b37bz.fsf <at> gnu.org>
and subject line Re: bug#65251: 30.0.50; Duration in compilation buffer
has caused the debbugs.gnu.org bug report #65251,
regarding 30.0.50; Duration in compilation buffer
to be marked as done.

(If you believe you have received this mail in error, please contact
help-debbugs <at> gnu.org.)


-- 
65251: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=65251
GNU Bug Tracking System
Contact help-debbugs <at> gnu.org with problems
[Message part 2 (message/rfc822, inline)]
From: Helmut Eller <eller.helmut <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: 30.0.50; Duration in compilation buffer
Date: Sat, 12 Aug 2023 20:30:51 +0200
[Message part 3 (text/plain, inline)]
In the *compilation* buffer, we see timestamps when the compilation
started and finished.  It would be nice to also see how long the
compilation command took.  The attached patch does that.  It looks like
this:

  Compilation finished at Sat Aug 12 20:23:57, 2.52s

Helmut

[0001-When-a-compilation-finishes-show-how-long-it-took.patch (text/x-diff, inline)]
From d6bdf293287a5f252de0cf2dd00cfeaff1c02f80 Mon Sep 17 00:00:00 2001
From: Helmut Eller <eller.helmut <at> gmail.com>
Date: Sat, 12 Aug 2023 19:17:43 +0200
Subject: [PATCH] When a compilation finishes, show how long it took

Insert the duration, not just the timestamp.

* lisp/progmodes/compile.el (compilation--start-time): New variable.
(compilation-start): Set it.
(compilation-handle-exit): Use it to compute the duration and
 insert it in human readable form.
---
 lisp/progmodes/compile.el | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/lisp/progmodes/compile.el b/lisp/progmodes/compile.el
index 6d151db8a83..276c9a5d3e1 100644
--- a/lisp/progmodes/compile.el
+++ b/lisp/progmodes/compile.el
@@ -1862,6 +1862,9 @@ compilation-insert-annotation
     (apply #'insert args)
     (put-text-property start (point) 'compilation-annotation t)))
 
+;; The time when the compilation started.
+(defvar compilation--start-time nil)
+
 ;;;###autoload
 (defun compilation-start (command &optional mode name-function highlight-regexp
                                   continue)
@@ -1993,6 +1996,7 @@ compilation-start
                  mode-name
 		 (substring (current-time-string) 0 19))
 	 command "\n")
+        (setq-local compilation--start-time (current-time))
 	(setq thisdir default-directory))
       (set-buffer-modified-p nil))
     ;; Pop up the compilation buffer.
@@ -2480,7 +2484,15 @@ compilation-handle-exit
 	(message "%s" (cdr status)))
     (if (bolp)
 	(forward-char -1))
-    (compilation-insert-annotation " at " (substring (current-time-string) 0 19))
+    (compilation-insert-annotation
+     " at "
+     (substring (current-time-string) 0 19)
+     ", "
+     (let* ((secs (float-time (time-since compilation--start-time))))
+       (cond ((< secs 1) (format "%.0fms" (* secs 1000)))
+	     ((< secs 10) (format "%.2fs" secs))
+	     ((< secs 60) (format "%.1fs" secs))
+	     (t (format-seconds "%hh%mm%z%ss" secs)))))
     (goto-char (point-max))
     ;; Prevent that message from being recognized as a compilation error.
     (add-text-properties omax (point)
-- 
2.39.2

[Message part 5 (message/rfc822, inline)]
From: Eli Zaretskii <eliz <at> gnu.org>
To: Helmut Eller <eller.helmut <at> gmail.com>
Cc: mattias.engdegard <at> gmail.com, 65251-done <at> debbugs.gnu.org
Subject: Re: bug#65251: 30.0.50; Duration in compilation buffer
Date: Sat, 19 Aug 2023 08:54:40 +0300
> From: Helmut Eller <eller.helmut <at> gmail.com>
> Cc: Eli Zaretskii <eliz <at> gnu.org>,  65251 <at> debbugs.gnu.org
> Date: Fri, 18 Aug 2023 22:55:10 +0200
> 
> On Fri, Aug 18 2023, Mattias EngdegÄrd wrote:
> 
> > Otherwise, if you aren't too unhappy about the resolution, the bug can
> > be closed.
> 
> Yes, close it.

Thanks, done.


This bug report was last modified 1 year and 275 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.