From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Helmut Eller Newsgroups: gmane.emacs.bugs Subject: bug#65251: 30.0.50; Duration in compilation buffer Date: Sat, 12 Aug 2023 20:30:51 +0200 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="1441"; mail-complaints-to="usenet@ciao.gmane.io" To: 65251@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sat Aug 12 20:32:13 2023 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1qUtPI-0000BU-Nb for geb-bug-gnu-emacs@m.gmane-mx.org; Sat, 12 Aug 2023 20:32:12 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qUtPC-0005TG-1q; Sat, 12 Aug 2023 14:32:06 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUtP9-0005T4-Nc for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 14:32:04 -0400 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qUtP8-0004OA-Ch for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 14:32:03 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qUtP8-0004w0-7U for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 14:32:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Helmut Eller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sat, 12 Aug 2023 18:32:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 65251 X-GNU-PR-Package: emacs X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.169186506718879 (code B ref -1); Sat, 12 Aug 2023 18:32:02 +0000 Original-Received: (at submit) by debbugs.gnu.org; 12 Aug 2023 18:31:07 +0000 Original-Received: from localhost ([127.0.0.1]:57436 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUtOE-0004uR-VQ for submit@debbugs.gnu.org; Sat, 12 Aug 2023 14:31:07 -0400 Original-Received: from lists.gnu.org ([2001:470:142::17]:33294) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qUtOC-0004tq-Uz for submit@debbugs.gnu.org; Sat, 12 Aug 2023 14:31:05 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qUtO7-0005Jq-34 for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 14:30:59 -0400 Original-Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qUtO4-0003YQ-6G for bug-gnu-emacs@gnu.org; Sat, 12 Aug 2023 14:30:58 -0400 Original-Received: by mail-wr1-x42a.google.com with SMTP id ffacd0b85a97d-31969580797so670047f8f.3 for ; Sat, 12 Aug 2023 11:30:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691865053; x=1692469853; h=mime-version:message-id:date:subject:to:from:from:to:cc:subject :date:message-id:reply-to; bh=EfRwO0esaLFoyenGbMMD3419SY8zPDQHC1gJ3gHJo1E=; b=kaEupdgmtl0YRO08p79frwpefFLMe8nYnvKWY+KD4CALUX5j2B7apVTSCxPbqA96lR IBXMb2JozqYqBaiUzzLFOY6wsv/gfGc4bhRB8E6mDQrdoUk8WcBLDuoapMWxP2+TLCDX mNX4WG4rkJ/UUOmraR08fUfzp+4AZBcVNx9JdOXpPh76NRKJm7yqsEsnWIEMMAcg1Q4x nqvPMsVoH48ve+5zycXXRfcEQ1F3tWn1iIVleKvC+dlJx9aO/7pEvOiUOsg3k1PM4u+z hhENQl2ljnjK3Q0aelOJQq/tA1YsWoFBMtEHKUsdhfhUIBJY80ARWdi0W5rGK6DegPGX l9ZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691865053; x=1692469853; h=mime-version:message-id:date:subject:to:from:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=EfRwO0esaLFoyenGbMMD3419SY8zPDQHC1gJ3gHJo1E=; b=aNb4U6C4p4SWdfpY6oTXk21v/U/zWgm/GBivKSA6BTbsj5wHSwN6YCTVQl2JCqg+N0 7IIadjXQMG4gGtFD1Ugj6CfPv6E521edH5wnl1s5dazIy0yelAQSNppW7nubiYFPSlJL UmcA8zGofsd2RGg6uILptzB2xe0ImKikwwCIxlX9GJxhOSIy21mSvZksQS2f/u7v+Qwb QGK3JmxnXD0KVTJvAqa2bIxE0m4Du+PbD+CvEqv5y7Y1L5Zx5Whv7FQApRoHp9eDWruO PqmL02GCFpXzZjPvi6pFHeMo9yRTnOpmG7Cci2s/fFDS9gP5VUw75rQ0zrdCyaSSd/sd 5exQ== X-Gm-Message-State: AOJu0YxsCkGqo0Iv0d4BP/AmoSezHiHmGfxW0ZthmjuXMkeLd0l6XxI5 ZTt8E4DHZapFluxYPLn30ZsQhzLmirc= X-Google-Smtp-Source: AGHT+IEIVbljtVgT11dh4rvtWMCp/UkVHRUln9De3EFsP4EfZ8Z2yvOQnBZZY8ZO7+GFumDwcKfR0Q== X-Received: by 2002:a05:6000:1181:b0:319:6bbe:5af5 with SMTP id g1-20020a056000118100b003196bbe5af5mr1326204wrx.3.1691865053393; Sat, 12 Aug 2023 11:30:53 -0700 (PDT) Original-Received: from caladan ([185.127.213.71]) by smtp.gmail.com with ESMTPSA id k7-20020adfe3c7000000b003176c6e87b1sm9211294wrm.81.2023.08.12.11.30.52 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 12 Aug 2023 11:30:52 -0700 (PDT) Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=eller.helmut@gmail.com; helo=mail-wr1-x42a.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:267328 Archived-At: --=-=-= Content-Type: text/plain 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 --=-=-= Content-Type: text/x-diff Content-Disposition: inline; filename=0001-When-a-compilation-finishes-show-how-long-it-took.patch >From d6bdf293287a5f252de0cf2dd00cfeaff1c02f80 Mon Sep 17 00:00:00 2001 From: Helmut Eller 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 --=-=-=--