[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
scratch/igc 8fcf11f1455: Collecting stats in CSV files at specified inte
From: |
Gerd Moellmann |
Subject: |
scratch/igc 8fcf11f1455: Collecting stats in CSV files at specified intervals |
Date: |
Sat, 29 Jun 2024 05:24:28 -0400 (EDT) |
branch: scratch/igc
commit 8fcf11f1455a21e3c811b55b58256ebd8a96be97
Author: Gerd Möllmann <gerd@gnu.org>
Commit: Gerd Möllmann <gerd@gnu.org>
Collecting stats in CSV files at specified intervals
---
lisp/emacs-lisp/igc.el | 31 +++++++++++++++++++++++++++++++
1 file changed, 31 insertions(+)
diff --git a/lisp/emacs-lisp/igc.el b/lisp/emacs-lisp/igc.el
index ebf409d72f1..93f3db6de86 100644
--- a/lisp/emacs-lisp/igc.el
+++ b/lisp/emacs-lisp/igc.el
@@ -231,4 +231,35 @@ the changes to snapshot A. See the modes's help."
(goto-char (point-min))))
(display-buffer "*igc roots*"))
+(defvar igc--collect-timer nil)
+(defvar igc--collect-file nil)
+
+(defun igc-stop-collecting-stats ()
+ (interactive)
+ (when igc--collect-timer
+ (cancel-timer igc--collect-timer)
+ (setq igc--collect-timer nil)))
+
+(defun igc--collect-stats ()
+ (let ((buffer (get-file-buffer igc--collect-file)))
+ (when buffer
+ (with-current-buffer buffer
+ (goto-char (point-max))
+ (when (= (point-min) (point-max))
+ (insert (format "\"%s\",\"%s\",\"%s\",\"%s\"\n"
+ "Time" "Type" "N" "Bytes")))
+ (cl-loop with time = (current-time-string)
+ for (title n bytes) in (igc-info) do
+ (insert (format "\"%s\",\"%s\",\"%s\",\"%s\"\n"
+ time title n bytes))))
+ (save-buffer))))
+
+(defun igc-start-collecting-stats (file secs)
+ "Start collecting statistics every SECS seconds."
+ (interactive "FOutput file: \nnInterval (seconds): ")
+ (igc-stop-collecting-stats)
+ (setq igc--collect-file file)
+ (find-file-noselect file)
+ (setq igc--collect-timer (run-at-time nil secs #'igc--collect-stats)))
+
(provide 'igc)
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- scratch/igc 8fcf11f1455: Collecting stats in CSV files at specified intervals,
Gerd Moellmann <=