[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/emacs-gc-stats 1a8cd5dd08 11/24: Add idle time counter
From: |
ELPA Syncer |
Subject: |
[elpa] externals/emacs-gc-stats 1a8cd5dd08 11/24: Add idle time counter |
Date: |
Sat, 10 Jun 2023 12:58:45 -0400 (EDT) |
branch: externals/emacs-gc-stats
commit 1a8cd5dd08cd5a84f63f83127a6715b40c3d0481
Author: Ihor Radchenko <yantar92@posteo.net>
Commit: Ihor Radchenko <yantar92@posteo.net>
Add idle time counter
* emacs-gc-stats.el (emacs-gc-stats-idle-delay): New variable. Number
of seconds to consider the time idle.
(emacs-gc-stats--idle-tic): New variable holding how many
`emacs-gc-stats-idle-delay' intervals Emacs was idle.
(emacs-gc-stats--idle-timer): New variable holding the timer.
(emacs-gc-stats-idle-tic): New function. Idle counter tic counter.
(emacs-gc-stats-mode): Run idle timer.
(emacs-gc-stats--command-vars):
(emacs-gc-stats--summary-vars): Record idle tic counter.
---
emacs-gc-stats.el | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
diff --git a/emacs-gc-stats.el b/emacs-gc-stats.el
index f41943ef55..39a46a9433 100644
--- a/emacs-gc-stats.el
+++ b/emacs-gc-stats.el
@@ -69,7 +69,8 @@
this-command
memory-limit
(memory-info)
- (memory-use-counts))
+ (memory-use-counts)
+ emacs-gc-stats--idle-tic)
"List of variable/function symbols to collect for each GC or command.")
(defvar emacs-gc-stats--summary-vars
@@ -80,7 +81,9 @@
memory-limit
(memory-info)
emacs-uptime
- (memory-use-counts))
+ (memory-use-counts)
+ emacs-gc-stats-idle-delay
+ emacs-gc-stats--idle-tic)
"List of variables to collect at session end.")
(defun emacs-gc-stats--collect (&rest symbols)
@@ -169,6 +172,19 @@ Otherwise, collect symbol."
(emacs-gc-stats-mode -1)
(emacs-gc-stats-mode +1)))
+(defvar emacs-gc-stats-idle-delay 300
+ "Delay in seconds to count idle time.")
+
+(defvar emacs-gc-stats--idle-tic 0
+ "Idle counter.")
+(defvar emacs-gc-stats--idle-timer nil
+ "Time counting idle time.")
+(defun emacs-gc-stats-idle-tic ()
+ "Increase idle counter."
+ (when (and (current-idle-time)
+ (> (time-to-seconds (current-idle-time))
emacs-gc-stats-idle-delay))
+ (cl-incf emacs-gc-stats--idle-tic)))
+
(define-minor-mode emacs-gc-stats-mode
"Toggle collecting Emacs GC statistics."
:global t
@@ -176,9 +192,17 @@ Otherwise, collect symbol."
(progn
(unless emacs-gc-stats--data
(emacs-gc-stats--collect-init))
+ ;; 5 minutes counter.
+ (setq emacs-gc-stats--idle-time
+ (run-with-timer
+ emacs-gc-stats-idle-delay
+ emacs-gc-stats-idle-delay
+ #'emacs-gc-stats-idle-tic))
(add-hook 'post-gc-hook #'emacs-gc-stats--collect-gc)
(add-hook 'after-init-hook #'emacs-gc-stats--collect-init-end)
(add-hook 'kill-emacs-hook #'emacs-gc-stats-save-session))
+ (when (timerp emacs-gc-stats--idle-time)
+ (cancel-timer emacs-gc-stats--idle-time))
(remove-hook 'post-gc-hook #'emacs-gc-stats--collect-gc)
(remove-hook 'after-init-hook #'emacs-gc-stats--collect-init-end)
(remove-hook 'kill-emacs-hook #'emacs-gc-stats-save-session)))
- [elpa] externals/emacs-gc-stats 048af820a7 06/24: emacs-gc-stats-save-session: Smarter repeated session data save, (continued)
- [elpa] externals/emacs-gc-stats 048af820a7 06/24: emacs-gc-stats-save-session: Smarter repeated session data save, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 9183a40b15 03/24: Do not use :time keyword in stat data, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats bc6fe1e960 10/24: Record `memory-info' output, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats e06240ad05 14/24: Add license, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats ec9b22d455 15/24: Add README, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats f317944684 19/24: reword README, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 248ade4f62 04/24: Add `emacs-gc-stats-clear' command, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats fdbb7251b4 07/24: Record init.el stats, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats e64d069950 08/24: Record `memory-info' on init only, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 30340df54c 18/24: Use Org for README source, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 1a8cd5dd08 11/24: Add idle time counter,
ELPA Syncer <=
- [elpa] externals/emacs-gc-stats c08135aeaa 12/24: Fix variable name, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 0725079b75 13/24: Fix linter warnings, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats d27c438dfc 16/24: Fix typo, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats c2c67c16b0 22/24: Add .elpaignore, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 1fe543c9b6 20/24: README: Link to my email, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats de80c141c6 21/24: * emacs-gc-stats.el: Add maintainer, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 7a454887a1 02/24: Initial implemention, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats 271ea760fc 09/24: Add some common Emacs distribution indicators, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats b2d59f0ff6 17/24: Reword README, ELPA Syncer, 2023/06/10
- [elpa] externals/emacs-gc-stats fc3792d67c 24/24: README: Typo, ELPA Syncer, 2023/06/10