aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard M. Stallman1994-12-24 04:27:01 +0000
committerRichard M. Stallman1994-12-24 04:27:01 +0000
commit5fe4899af75bdd5ad057d35f0b4f2f322b1dc2d7 (patch)
treee92024d4100c5a4ab8bc50c54586cb553fc6bfa7
parent8ea231fcaccf51358be485271c44ec9aeda337e1 (diff)
downloademacs-5fe4899af75bdd5ad057d35f0b4f2f322b1dc2d7.tar.gz
emacs-5fe4899af75bdd5ad057d35f0b4f2f322b1dc2d7.zip
(elp-pack-number): New function.
(elp-output-results): Use elp-pack-number to truncate time strings, watching out for very small or very large numbers. (elp-unset-master): Make it an interactive command.
-rw-r--r--lisp/emacs-lisp/elp.el68
1 files changed, 46 insertions, 22 deletions
diff --git a/lisp/emacs-lisp/elp.el b/lisp/emacs-lisp/elp.el
index 0b421d10224..bbdf5b96cb0 100644
--- a/lisp/emacs-lisp/elp.el
+++ b/lisp/emacs-lisp/elp.el
@@ -1,12 +1,13 @@
1;;; elp.el --- Emacs Lisp Profiler 1;;; elp.el --- Emacs Lisp Profiler
2 2
3;; Copyright (C) 1994 Barry A. Warsaw
3;; Copyright (C) 1994 Free Software Foundation, Inc. 4;; Copyright (C) 1994 Free Software Foundation, Inc.
4 5
5;; Author: 1994 Barry A. Warsaw <bwarsaw@cnri.reston.va.us> 6;; Author: 1994 Barry A. Warsaw <bwarsaw@cnri.reston.va.us>
6;; Maintainer: tools-help@anthem.nlm.nih.gov 7;; Maintainer: tools-help@anthem.nlm.nih.gov
7;; Created: 26-Feb-1994 8;; Created: 26-Feb-1994
8;; Version: 2.18 9;; Version: 2.22
9;; Last Modified: 1994/09/14 14:00:09 10;; Last Modified: 1994/12/23 17:46:21
10;; Keywords: Emacs Lisp Profile Timing 11;; Keywords: Emacs Lisp Profile Timing
11 12
12;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
@@ -32,8 +33,8 @@
32;; profiler.el. Both were written for Emacs 18 and both were pretty 33;; profiler.el. Both were written for Emacs 18 and both were pretty
33;; good first shots at profiling, but I found that they didn't provide 34;; good first shots at profiling, but I found that they didn't provide
34;; the functionality or interface that I wanted. So I wrote this. 35;; the functionality or interface that I wanted. So I wrote this.
35;; I've tested elp in Lucid Emacs 19.9 and Emacs 19.22. There's no 36;; I've tested elp in both Emacs 19's. There's no point in even
36;; point in even trying to make this work with Emacs 18. 37;; trying to make this work with Emacs 18.
37 38
38;; Unlike previous profilers, elp uses Emacs 19's built-in function 39;; Unlike previous profilers, elp uses Emacs 19's built-in function
39;; current-time to return interval times. This obviates the need for 40;; current-time to return interval times. This obviates the need for
@@ -54,8 +55,11 @@
54;; are calculated using wall-clock time, so other system load will 55;; are calculated using wall-clock time, so other system load will
55;; affect accuracy too. 56;; affect accuracy too.
56 57
57;; There are only 3 variables you can change to customize behavior of 58;; Here is a list of variable you can use to customize elp:
58;; elp. See below for their description. 59;; elp-function-list
60;; elp-reset-after-results
61;; elp-sort-by-function
62;; elp-report-limit
59;; 63;;
60;; Here is a list of the interactive commands you can use: 64;; Here is a list of the interactive commands you can use:
61;; elp-instrument-function 65;; elp-instrument-function
@@ -67,6 +71,8 @@
67;; elp-reset-function 71;; elp-reset-function
68;; elp-reset-list 72;; elp-reset-list
69;; elp-reset-all 73;; elp-reset-all
74;; elp-set-master
75;; elp-unset-master
70;; elp-results 76;; elp-results
71;; elp-submit-bug-report 77;; elp-submit-bug-report
72;; 78;;
@@ -76,12 +82,12 @@
76;; information is recorded whenever they are called. To print out the 82;; information is recorded whenever they are called. To print out the
77;; current results, use elp-results. With elp-reset-after-results set 83;; current results, use elp-results. With elp-reset-after-results set
78;; to non-nil, profiling information will be reset whenever the 84;; to non-nil, profiling information will be reset whenever the
79;; results are displayed. You can also reset all profiling info at any 85;; results are displayed. You can also reset all profiling info at
80;; time with elp-reset-all. 86;; any time with elp-reset-all.
81;; 87;;
82;; You can also instrument all functions in a package, provided that 88;; You can also instrument all functions in a package, provided that
83;; the package follows the GNU coding standard of a common textural 89;; the package follows the GNU coding standard of a common textural
84;; prefix. elp-instrument-package does this. 90;; prefix. Use the elp-instrument-package command for this.
85;; 91;;
86;; If you want to sort the results, set elp-sort-by-function to some 92;; If you want to sort the results, set elp-sort-by-function to some
87;; predicate function. The three most obvious choices are predefined: 93;; predicate function. The three most obvious choices are predefined:
@@ -92,8 +98,8 @@
92;; 98;;
93;; Elp can instrument byte-compiled functions just as easily as 99;; Elp can instrument byte-compiled functions just as easily as
94;; interpreted functions, but it cannot instrument macros. However, 100;; interpreted functions, but it cannot instrument macros. However,
95;; when you redefine a function (e.g. with eval-defun), you'll need 101;; when you redefine a function (e.g. with eval-defun), you'll need to
96;; to re-instrument it with elp-instrument-function. Re-instrumenting 102;; re-instrument it with elp-instrument-function. Re-instrumenting
97;; resets profiling information for that function. Elp can also 103;; resets profiling information for that function. Elp can also
98;; handle interactive functions (i.e. commands), but of course any 104;; handle interactive functions (i.e. commands), but of course any
99;; time spent idling for user prompts will show up in the timing 105;; time spent idling for user prompts will show up in the timing
@@ -108,8 +114,8 @@
108;; (defun baz () (bar) (foo)) 114;; (defun baz () (bar) (foo))
109;; 115;;
110;; and you want to find out the amount of time spent in bar and foo, 116;; and you want to find out the amount of time spent in bar and foo,
111;; but only during execution of bar, make bar the master and the call 117;; but only during execution of bar, make bar the master. The call of
112;; of foo from baz will not add to foo's total timing sums. Use 118;; foo from baz will not add to foo's total timing sums. Use
113;; elp-set-master and elp-unset-master to utilize this feature. Only 119;; elp-set-master and elp-unset-master to utilize this feature. Only
114;; one master function can be used at a time. 120;; one master function can be used at a time.
115 121
@@ -117,6 +123,11 @@
117;; elp-restore-function. The other instrument, restore, and reset 123;; elp-restore-function. The other instrument, restore, and reset
118;; functions are provided for symmetry. 124;; functions are provided for symmetry.
119 125
126;; LCD Archive Entry:
127;; elp|Barry A. Warsaw|tools-help@anthem.nlm.nih.gov|
128;; Emacs Lisp Profiler|
129;; 1994/12/23 17:46:21|2.22|~/misc/elp.el.Z|
130
120;;; Code: 131;;; Code:
121 132
122 133
@@ -156,7 +167,7 @@ functions will be displayed.")
156;; end user configuration variables 167;; end user configuration variables
157 168
158 169
159(defconst elp-version "2.18" 170(defconst elp-version "2.22"
160 "ELP version number.") 171 "ELP version number.")
161 172
162(defconst elp-help-address "tools-help@anthem.nlm.nih.gov" 173(defconst elp-help-address "tools-help@anthem.nlm.nih.gov"
@@ -336,6 +347,7 @@ Use optional LIST if provided instead."
336 347
337(defun elp-unset-master () 348(defun elp-unset-master ()
338 "Unsets the master function." 349 "Unsets the master function."
350 (interactive)
339 ;; when there's no master function, recording is turned on by default. 351 ;; when there's no master function, recording is turned on by default.
340 (setq elp-master nil 352 (setq elp-master nil
341 elp-record-p t)) 353 elp-record-p t))
@@ -408,6 +420,21 @@ original definition, use \\[elp-restore-function] or \\[elp-restore-all]."
408 ;; sort by highest average time spent in function. See `sort'. 420 ;; sort by highest average time spent in function. See `sort'.
409 (>= (aref vec1 2) (aref vec2 2))) 421 (>= (aref vec1 2) (aref vec2 2)))
410 422
423(defsubst elp-pack-number (number width)
424 ;; pack the NUMBER string into WIDTH characters, watching out for
425 ;; very small or large numbers
426 (if (<= (length number) width)
427 number
428 ;; check for very large or small numbers
429 (if (string-match "^\\(.*\\)\\(e[+-].*\\)$" number)
430 (concat (substring
431 (substring number (match-beginning 1) (match-end 1))
432 0
433 (- width (match-end 2) (- (match-beginning 2)) 3))
434 "..."
435 (substring number (match-beginning 2) (match-end 2)))
436 (concat (substring number 0 width)))))
437
411(defun elp-output-result (resultvec) 438(defun elp-output-result (resultvec)
412 ;; output the RESULTVEC into the results buffer. RESULTVEC is a 4 or 439 ;; output the RESULTVEC into the results buffer. RESULTVEC is a 4 or
413 ;; more element vector where aref 0 is the call count, aref 1 is the 440 ;; more element vector where aref 0 is the call count, aref 1 is the
@@ -432,13 +459,11 @@ original definition, use \\[elp-restore-function] or \\[elp-restore-all]."
432 ;; print stuff out, formatting it nicely 459 ;; print stuff out, formatting it nicely
433 (insert callcnt) 460 (insert callcnt)
434 (insert-char 32 (+ elp-cc-len (- (length callcnt)) 2)) 461 (insert-char 32 (+ elp-cc-len (- (length callcnt)) 2))
435 (if (> (length totaltime) elp-et-len) 462 (let ((ttstr (elp-pack-number totaltime elp-et-len))
436 (insert (substring totaltime 0 elp-et-len) " ") 463 (atstr (elp-pack-number avetime elp-at-len)))
437 (insert totaltime) 464 (insert ttstr)
438 (insert-char 32 (+ elp-et-len (- (length totaltime)) 2))) 465 (insert-char 32 (+ elp-et-len (- (length ttstr)) 2))
439 (if (> (length avetime) elp-at-len) 466 (insert atstr))
440 (insert (substring avetime 0 elp-at-len))
441 (insert avetime))
442 (insert "\n")))) 467 (insert "\n"))))
443 468
444;;;###autoload 469;;;###autoload
@@ -528,5 +553,4 @@ displayed."
528 553
529 554
530(provide 'elp) 555(provide 'elp)
531
532;; elp.el ends here 556;; elp.el ends here