From 3ab6e069695d0dd5bb77133a89f858190ab8550a Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 18 Jul 2012 09:44:36 +0400 Subject: Return more descriptive data from Fgarbage_collect. Suggested by Stefan Monnier in http://lists.gnu.org/archive/html/emacs-devel/2012-07/msg00369.html. * src/alloc.c (bounded_number): New function. (total_buffers, total_vectors): New variable. (total_string_size): Rename to total_string_bytes, adjust users. (total_vector_size): Rename to total_vector_bytes, adjust users. (sweep_vectors): Account total_vectors and total_vector_bytes. (Fgarbage_collect): New return value. Adjust documentation. (gc_sweep): Account total_buffers. (Fmemory_free, Fmemory_use_counts): Use bounded_number. (VECTOR_SIZE): Remove. * src/data.c (Qfloat, Qvector, Qsymbol, Qstring, Qcons): Make global. (Qinterval, Qmisc): New symbols. (syms_of_data): Initialize them. * src/lisp.h (Qinterval, Qsymbol, Qstring, Qmisc, Qvector, Qfloat) (Qcons, Qbuffer): New declarations. * lisp/emacs-lisp/chart.el (chart-emacs-storage): Change to reflect new format of data returned by Fgarbage_collect. --- lisp/emacs-lisp/chart.el | 36 +++++++++++++++++++----------------- 1 file changed, 19 insertions(+), 17 deletions(-) (limited to 'lisp/emacs-lisp') diff --git a/lisp/emacs-lisp/chart.el b/lisp/emacs-lisp/chart.el index 74087014d69..5699d827d4f 100644 --- a/lisp/emacs-lisp/chart.el +++ b/lisp/emacs-lisp/chart.el @@ -676,23 +676,25 @@ SORT-PRED if desired." "Chart the current storage requirements of Emacs." (interactive) (let* ((data (garbage-collect)) - (names '("strings/2" "vectors" - "conses" "free cons" - "syms" "free syms" - "markers" "free mark" - ;; "floats" "free flt" - )) - (nums (list (/ (nth 3 data) 2) - (nth 4 data) - (car (car data)) ; conses - (cdr (car data)) - (car (nth 1 data)) ; syms - (cdr (nth 1 data)) - (car (nth 2 data)) ; markers - (cdr (nth 2 data)) - ;(car (nth 5 data)) ; floats are Emacs only - ;(cdr (nth 5 data)) - ))) + (cons-info (nth 0 data)) + (symbol-info (nth 1 data)) + (misc-info (nth 2 data)) + (string-info (nth 3 data)) + (vector-info (nth 4 data)) + (float-info (nth 5 data)) + (interval-info (nth 6 data)) + (buffer-info (nth 7 data)) + (names '("conses" "symbols" "miscs" "strings" + "vectors" "floats" "intervals" "buffers")) + (nums (list (* (nth 1 cons-info) (nth 2 cons-info)) + (* (nth 1 symbol-info) (nth 2 symbol-info)) + (* (nth 1 misc-info) (nth 2 misc-info)) + (+ (* (nth 1 string-info) (nth 2 string-info)) + (nth 3 string-info)) + (nth 3 vector-info) + (* (nth 1 float-info) (nth 2 float-info)) + (* (nth 1 interval-info) (nth 2 interval-info)) + (* (nth 1 buffer-info) (nth 2 buffer-info))))) ;; Let's create the chart! (chart-bar-quickie 'vertical "Emacs Runtime Storage Usage" names "Storage Items" -- cgit v1.2.3