annotate lisp/diagnose.el @ 2931:0d5322818981

[xemacs-hg @ 2005-09-14 05:28:38 by stephent] XEmacs 21.5.22 "cucumber" is released.
author stephent
date Wed, 14 Sep 2005 05:31:02 +0000
parents 05d62157e048
children 876730d84b73
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
1 ;;; diagnose.el --- routines for debugging problems in XEmacs
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
2
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
3 ;; Copyright (C) 2002 Ben Wing.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
4
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
5 ;; Maintainer: XEmacs Development Team
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
6 ;; Keywords: dumped
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
7
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
8 ;; This file is part of XEmacs.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
9
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
10 ;; XEmacs is free software; you can redistribute it and/or modify it
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
11 ;; under the terms of the GNU General Public License as published by
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
12 ;; the Free Software Foundation; either version 2, or (at your option)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
13 ;; any later version.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
14
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
15 ;; XEmacs is distributed in the hope that it will be useful, but
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
16 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
17 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
18 ;; General Public License for more details.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
19
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
20 ;; You should have received a copy of the GNU General Public License
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
21 ;; along with XEmacs; see the file COPYING. If not, write to the Free
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
22 ;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
23 ;; 02111-1307, USA.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
24
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
25 ;;; Synched up with: Not in FSF.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
26
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
27 ;;; Commentary:
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
28
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
29 ;; This file is dumped with XEmacs.
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
30
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
31 ;;; Code:
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
32
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
33
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
34 (defun show-memory-usage ()
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
35 "Show statistics about memory usage of various sorts in XEmacs."
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
36 (interactive)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
37 (garbage-collect)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
38 (flet ((show-foo-stats (objtypename objlist memfun)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
39 (let* ((hash (make-hash-table))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
40 (first t)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
41 types fmt
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
42 (objnamelen 25)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
43 (linelen objnamelen)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
44 (totaltotal 0))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
45 (dolist (obj objlist)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
46 (let ((total 0)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
47 (stats (funcall memfun obj)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
48 (loop for (type . num) in stats while type do
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
49 (puthash type (+ num (or (gethash type hash) 0)) hash)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
50 (incf total num)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
51 (if first (push type types)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
52 (incf totaltotal total)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
53 (when first
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
54 (setq types (nreverse types))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
55 (setq fmt (concat
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
56 (format "%%-%ds" objnamelen)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
57 (mapconcat
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
58 #'(lambda (type)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
59 (let ((fieldlen
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
60 (max 8 (+ 2 (length
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
61 (symbol-name type))))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
62 (incf linelen fieldlen)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
63 (format "%%%ds" fieldlen)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
64 types "")
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
65 (progn (incf linelen 9) "%9s\n")))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
66 (princ "\n")
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
67 (princ (apply 'format fmt objtypename
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
68 (append types (list 'total))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
69 (princ (make-string linelen ?-))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
70 (princ "\n"))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
71 (let ((objname (format "%s" obj)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
72 (princ (apply 'format fmt (substring objname 0
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
73 (min (length objname)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
74 (1- objnamelen)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
75 (nconc (mapcar #'(lambda (type)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
76 (cdr (assq type stats)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
77 types)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
78 (list total)))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
79 (setq first nil)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
80 (princ "\n")
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
81 (princ (apply 'format fmt "total"
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
82 (nconc (mapcar #'(lambda (type)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
83 (gethash type hash))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
84 types)
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
85 (list totaltotal))))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
86 totaltotal)))
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
87
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
88 (let ((grandtotal 0)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
89 (buffer "*memory usage*")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
90 begin)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
91 (with-output-to-temp-buffer buffer
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
92 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
93 (set-buffer buffer)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
94 (when-fboundp 'charset-list
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
95 (setq begin (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
96 (incf grandtotal
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
97 (show-foo-stats 'charset (charset-list)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
98 #'charset-memory-usage))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
99 (sort-numeric-fields -1
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
100 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
101 (goto-char begin)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
102 (forward-line 2)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
103 (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
104 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
105 (forward-line -2)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
106 (point)))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
107 (princ "\n"))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
108 (setq begin (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
109 (incf grandtotal
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
110 (show-foo-stats 'buffer (buffer-list) #'buffer-memory-usage))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
111 (sort-numeric-fields -1
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
112 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
113 (goto-char begin)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
114 (forward-line 3)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
115 (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
116 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
117 (forward-line -2)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
118 (point)))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
119 (princ "\n")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
120 (setq begin (point))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
121 (incf grandtotal
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
122 (show-foo-stats 'window (mapcan #'(lambda (fr)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
123 (window-list fr t))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
124 (frame-list))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
125 #'window-memory-usage))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
126 (sort-numeric-fields -1
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
127 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
128 (goto-char begin)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
129 (forward-line 3)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
130 (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
131 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
132 (forward-line -2)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
133 (point)))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
134 (princ "\n")
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
135 (let ((total 0)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
136 (fmt "%-30s%10s\n"))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
137 (setq begin (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
138 (princ (format fmt "object" "storage"))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
139 (princ (make-string 40 ?-))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
140 (princ "\n")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
141 (map-plist #'(lambda (stat num)
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
142 (when (string-match
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
143 "\\(.*\\)-storage\\(-additional\\)?$"
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
144 (symbol-name stat))
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
145 (incf total num)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
146 (princ (format fmt
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
147 (match-string 1 (symbol-name stat))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
148 num)))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
149 (when (eq stat 'long-strings-total-length)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
150 (incf total num)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
151 (princ (format fmt stat num))))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
152 (sixth (garbage-collect)))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
153 (princ "\n")
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
154 (princ (format fmt "total" total))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
155 (incf grandtotal total))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
156 (sort-numeric-fields -1
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
157 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
158 (goto-char begin)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
159 (forward-line 2)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
160 (point))
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
161 (save-excursion
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
162 (forward-line -2)
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
163 (point)))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
164
2618
6db7dbf7f88b [xemacs-hg @ 2005-02-28 07:43:17 by adrian]
adrian
parents: 787
diff changeset
165 (princ (format "\n\ngrand total: %s\n" grandtotal)))
787
242b62e9fc59 [xemacs-hg @ 2002-03-20 10:20:48 by ben]
ben
parents:
diff changeset
166 grandtotal))))
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
167
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
168
2775
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
169 (defun show-lrecord-stats ()
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
170 "Show statistics about lrecord usage in XEmacs."
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
171 (interactive)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
172 (garbage-collect)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
173 (let ((buffer "*lrecord statistics*")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
174 (plist (lrecord-stats))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
175 (fmt "%-30s%10s%10s\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
176 (grandtotal 0)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
177 begin)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
178 (flet ((show-stats (match-string)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
179 (princ (format fmt "object" "count" "storage"))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
180 (princ (make-string 50 ?-))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
181 (princ "\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
182 (let ((total-use 0)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
183 (total-use-overhead 0)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
184 (total-count 0))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
185 (map-plist
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
186 #'(lambda (stat num)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
187 (when (string-match match-string
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
188 (symbol-name stat))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
189 (let ((storage-use num)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
190 (storage-use-overhead
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
191 (plist-get
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
192 plist
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
193 (intern (concat (match-string 1 (symbol-name stat))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
194 "-storage-including-overhead"))))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
195 (storage-count
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
196 (or (plist-get
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
197 plist
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
198 (intern
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
199 (concat (match-string 1 (symbol-name stat))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
200 "s-used")))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
201 (plist-get
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
202 plist
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
203 (intern
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
204 (concat (match-string 1 (symbol-name stat))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
205 "es-used")))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
206 (plist-get
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
207 plist
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
208 (intern
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
209 (concat (match-string 1 (symbol-name stat))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
210 "-used"))))))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
211 (incf total-use storage-use)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
212 (incf total-use-overhead (if storage-use-overhead
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
213 storage-use-overhead
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
214 storage-use))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
215 (incf total-count storage-count)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
216 (princ (format fmt
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
217 (match-string 1 (symbol-name stat))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
218 storage-count storage-use)))))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
219 plist)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
220 (princ "\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
221 (princ (format fmt "total"
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
222 total-count total-use-overhead))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
223 (incf grandtotal total-use-overhead)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
224 (sort-numeric-fields -1
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
225 (save-excursion
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
226 (goto-char begin)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
227 (forward-line 2)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
228 (point))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
229 (save-excursion
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
230 (forward-line -2)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
231 (point))))))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
232 (with-output-to-temp-buffer buffer
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
233 (save-excursion
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
234 (set-buffer buffer)
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
235 (setq begin (point))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
236 (princ "Allocated with new allocator:\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
237 (show-stats "\\(.*\\)-storage$")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
238 (princ "\n\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
239 (setq begin (point))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
240 (princ "Allocated additionally:\n")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
241 (show-stats "\\(.*\\)-storage-additional$")
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
242 (princ (format "\n\ngrand total: %s\n" grandtotal)))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
243 grandtotal))))
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
244
05d62157e048 [xemacs-hg @ 2005-05-15 16:37:52 by crestani]
crestani
parents: 2720
diff changeset
245
2720
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
246 (defun show-mc-alloc-memory-usage ()
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
247 "Show statistics about memory usage of the new allocator."
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
248 (interactive)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
249 (garbage-collect)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
250 (let* ((stats (mc-alloc-memory-usage))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
251 (page-size (first stats))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
252 (heap-sects (second stats))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
253 (used-plhs (third stats))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
254 (unmanaged-plhs (fourth stats))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
255 (free-plhs (fifth stats))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
256 (globals (sixth stats))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
257 (mc-malloced-bytes (seventh stats)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
258 (with-output-to-temp-buffer "*memory usage*"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
259 (flet ((print-used-plhs (text plhs)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
260 (let ((sum-n-pages 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
261 (sum-used-n-cells 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
262 (sum-used-space 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
263 (sum-used-total 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
264 (sum-total-n-cells 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
265 (sum-total-space 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
266 (sum-total-total 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
267 (fmt "%7s%7s|%7s%9s%9s%4s|%7s%9s%9s%4s|%4s\n"))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
268 (princ (format "%-14s|%-29s|%-29s|\n"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
269 text
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
270 " currently in use"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
271 " total available"))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
272 (princ (format fmt "cell-sz" "#pages"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
273 "#cells" "space" "total" "% "
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
274 "#cells" "space" "total" "% " "% "))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
275 (princ (make-string 79 ?-))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
276 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
277 (while plhs
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
278 (let* ((elem (car plhs))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
279 (cell-size (first elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
280 (n-pages (second elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
281 (used-n-cells (third elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
282 (used-space (fourth elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
283 (used-total (if (zerop cell-size)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
284 (sixth elem)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
285 (* cell-size used-n-cells)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
286 (used-eff (floor (if (not (zerop used-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
287 (* (/ (* used-space 1.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
288 (* used-total 1.0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
289 100.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
290 0)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
291 (total-n-cells (fifth elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
292 (total-space (if (zerop cell-size)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
293 used-space
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
294 (* cell-size total-n-cells)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
295 (total-total (sixth elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
296 (total-eff (floor (if (not (zerop total-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
297 (* (/ (* total-space 1.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
298 (* total-total 1.0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
299 100.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
300 0)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
301 (eff (floor (if (not (zerop total-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
302 (* (/ (* used-space 1.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
303 (* total-total 1.0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
304 100.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
305 0))))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
306 (princ (format fmt
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
307 cell-size n-pages used-n-cells used-space
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
308 used-total used-eff total-n-cells
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
309 total-space total-total total-eff eff))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
310 (incf sum-n-pages n-pages)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
311 (incf sum-used-n-cells used-n-cells)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
312 (incf sum-used-space used-space)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
313 (incf sum-used-total used-total)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
314 (incf sum-total-n-cells total-n-cells)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
315 (incf sum-total-space total-space)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
316 (incf sum-total-total total-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
317 (setq plhs (cdr plhs)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
318 (let ((avg-used-eff (floor (if (not (zerop sum-used-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
319 (* (/ (* sum-used-space 1.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
320 (* sum-used-total 1.0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
321 100.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
322 0)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
323 (avg-total-eff (floor (if (not (zerop sum-total-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
324 (* (/ (* sum-total-space 1.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
325 (* sum-total-total 1.0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
326 100.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
327 0)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
328 (avg-eff (floor (if (not (zerop sum-total-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
329 (* (/ (* sum-used-space 1.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
330 (* sum-total-total 1.0))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
331 100.0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
332 0))))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
333 (princ (format fmt "sum " sum-n-pages sum-used-n-cells
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
334 sum-used-space sum-used-total avg-used-eff
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
335 sum-total-n-cells sum-total-space
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
336 sum-total-total avg-total-eff avg-eff))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
337 (princ "\n"))))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
338
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
339
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
340 (print-free-plhs (text plhs)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
341 (let ((sum-n-pages 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
342 (sum-n-sects 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
343 (sum-space 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
344 (sum-total 0)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
345 (fmt "%6s%10s |%7s%10s\n"))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
346 (princ (format "%s\n" text))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
347 (princ (format fmt "#pages" "space" "#sects" "total"))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
348 (princ (make-string 35 ?-))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
349 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
350 (while plhs
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
351 (let* ((elem (car plhs))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
352 (n-pages (first elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
353 (n-sects (second elem))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
354 (space (* n-pages page-size))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
355 (total (* n-sects space)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
356 (princ (format fmt n-pages space n-sects total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
357 (incf sum-n-pages n-pages)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
358 (incf sum-n-sects n-sects)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
359 (incf sum-space space)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
360 (incf sum-total total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
361 (setq plhs (cdr plhs)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
362 (princ (make-string 35 ?=))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
363 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
364 (princ (format fmt sum-n-pages sum-space
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
365 sum-n-sects sum-total))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
366 (princ "\n"))))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
367
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
368 (princ (format "%-12s%10s\n\n" "PAGE_SIZE" page-size))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
369
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
370 (print-used-plhs "USED HEAP" used-plhs)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
371 (princ "\n\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
372
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
373 (print-used-plhs "UNMANAGED HEAP" unmanaged-plhs)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
374 (princ "\n\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
375
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
376 (print-free-plhs "FREE HEAP" free-plhs)
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
377 (princ "\n\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
378
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
379 (let ((fmt "%-30s%10s\n"))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
380 (princ (format fmt "heap sections" ""))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
381 (princ (make-string 40 ?-))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
382 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
383 (princ (format fmt "number of heap sects"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
384 (first heap-sects)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
385 (princ (format fmt "used size" (second heap-sects)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
386 (princ (make-string 40 ?-))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
387 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
388 (princ (format fmt "real size" (third heap-sects)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
389 (princ (format fmt "global allocator structs" globals))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
390 (princ (make-string 40 ?-))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
391 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
392 (princ (format fmt "real size + structs"
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
393 (+ (third heap-sects) globals)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
394 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
395 (princ (make-string 40 ?=))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
396 (princ "\n")
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
397 (princ (format fmt "grand total" mc-malloced-bytes)))
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
398
6fa9919a9a0b [xemacs-hg @ 2005-04-08 23:10:01 by crestani]
crestani
parents: 2618
diff changeset
399 (+ mc-malloced-bytes)))))