annotate lisp/utils/elp.el @ 172:a38aed19690b

Added tag r20-3b12 for changeset 929b76928fce
author cvs
date Mon, 13 Aug 2007 09:47:55 +0200
parents cca96a509cfe
children 6075d714658b
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 ;;; elp.el --- Emacs Lisp Profiler
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 ;; Copyright (C) 1994 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
5 ;; Author: 1994-1996 Barry A. Warsaw
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
6 ;; Maintainer: tools-help@python.org
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 ;; Created: 26-Feb-1994
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
8 ;; Version: 2.37
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
9 ;; Last Modified: 1996/10/23 04:06:58
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 ;; Keywords: debugging lisp tools
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ;; This file is part of GNU Emacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 ;; GNU Emacs is free software; you can redistribute it and/or modify
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ;; it under the terms of the GNU General Public License as published by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 ;; the Free Software Foundation; either version 2, or (at your option)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 ;; any later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 ;; GNU Emacs is distributed in the hope that it will be useful,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 ;; GNU General Public License for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 ;; You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25 ;; along with GNU Emacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 ;; the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 ;;; Commentary:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 ;; If you want to profile a bunch of functions, set elp-function-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 ;; to the list of symbols, then do a M-x elp-instrument-list. This
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 ;; hacks those functions so that profiling information is recorded
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 ;; whenever they are called. To print out the current results, use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 ;; M-x elp-results. If you want output to go to standard-output
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 ;; instead of a separate buffer, setq elp-use-standard-output to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 ;; non-nil. With elp-reset-after-results set to non-nil, profiling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 ;; information will be reset whenever the results are displayed. You
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 ;; can also reset all profiling info at any time with M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39 ;; elp-reset-all.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 ;; You can also instrument all functions in a package, provided that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 ;; the package follows the GNU coding standard of a common textural
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 ;; prefix. Use M-x elp-instrument-package for this.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 ;; If you want to sort the results, set elp-sort-by-function to some
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 ;; predicate function. The three most obvious choices are predefined:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 ;; elp-sort-by-call-count, elp-sort-by-average-time, and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 ;; elp-sort-by-total-time. Also, you can prune from the output, all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 ;; functions that have been called fewer than a given number of times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 ;; by setting elp-report-limit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 ;; Elp can instrument byte-compiled functions just as easily as
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53 ;; interpreted functions, but it cannot instrument macros. However,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 ;; when you redefine a function (e.g. with eval-defun), you'll need to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 ;; re-instrument it with M-x elp-instrument-function. This will also
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 ;; reset profiling information for that function. Elp can handle
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 ;; interactive functions (i.e. commands), but of course any time spent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 ;; idling for user prompts will show up in the timing results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 ;; You can also designate a `master' function. Profiling times will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 ;; be gathered for instrumented functions only during execution of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 ;; this master function. Thus, if you have some defuns like:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 ;; (defun foo () (do-something-time-intensive))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 ;; (defun bar () (foo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 ;; (defun baz () (bar) (foo))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 ;; and you want to find out the amount of time spent in bar and foo,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 ;; but only during execution of bar, make bar the master. The call of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
70 ;; foo from baz will not add to foo's total timing sums. Use M-x
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 ;; elp-set-master and M-x elp-unset-master to utilize this feature.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 ;; Only one master function can be set at a time.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 ;; You can restore any function's original function definition with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 ;; elp-restore-function. The other instrument, restore, and reset
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 ;; functions are provided for symmetry.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 ;; Here is a list of variable you can use to customize elp:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 ;; elp-function-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 ;; elp-reset-after-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 ;; elp-sort-by-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 ;; elp-report-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 ;; Here is a list of the interactive commands you can use:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 ;; elp-instrument-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 ;; elp-restore-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 ;; elp-instrument-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88 ;; elp-restore-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 ;; elp-instrument-package
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
90 ;; elp-restore-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91 ;; elp-reset-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 ;; elp-reset-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 ;; elp-reset-all
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 ;; elp-set-master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95 ;; elp-unset-master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
96 ;; elp-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
97 ;; elp-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
98
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 ;; Note that there are plenty of factors that could make the times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 ;; reported unreliable, including the accuracy and granularity of your
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 ;; system clock, and the overhead spent in lisp calculating and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 ;; recording the intervals. I figure the latter is pretty constant,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 ;; so while the times may not be entirely accurate, I think they'll
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 ;; give you a good feel for the relative amount of work spent in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 ;; various lisp routines you are profiling. Note further that times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 ;; are calculated using wall-clock time, so other system load will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 ;; affect accuracy too. You cannot profile anything longer than ~18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 ;; hours since I throw away the most significant 16 bits of seconds
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109 ;; returned by current-time: 2^16 == 65536 seconds == ~1092 minutes ==
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110 ;; ~18 hours. I doubt you will ever want to profile stuff on the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 ;; order of 18 hours anyway.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
112
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 ;;; Background:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 ;; This program was inspired by the only two existing Emacs Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 ;; profilers that I'm aware of, Boaz Ben-Zvi's profile.el, and Root
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 ;; Boy Jim's profiler.el. Both were written for Emacs 18 and both were
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 ;; pretty good first shots at profiling, but I found that they didn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119 ;; provide the functionality or interface that I wanted, so I wrote
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 ;; this. I've tested elp in XEmacs 19 and Emacs 19. There's no point
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ;; in even trying to make this work with Emacs 18.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 ;; Unlike previous profilers, elp uses Emacs 19's built-in function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 ;; current-time to return interval times. This obviates the need for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 ;; both an external C program and Emacs processes to communicate with
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 ;; such a program, and thus simplifies the package as a whole.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128 ;; TBD:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 ;; Make this act like a real profiler, so that it records time spent
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 ;; in all branches of execution.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
132 ;;; Code:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 ;; start of user configuration variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 ;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
138 (defgroup elp nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
139 "Emacs Lisp Profiler"
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
140 :group 'lisp)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
141
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
143 (defcustom elp-function-list nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
144 "*List of functions to profile.
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
145 Used by the command `elp-instrument-list'."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
146 :type '(repeat function)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
147 :group 'elp)
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
148
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
149 (defcustom elp-reset-after-results t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 "*Non-nil means reset all profiling info after results are displayed.
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
151 Results are displayed with the `elp-results' command."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
152 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
153 :group 'elp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
155 (defcustom elp-sort-by-function 'elp-sort-by-total-time
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 "*Non-nil specifies elp results sorting function.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 These functions are currently available:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 elp-sort-by-call-count -- sort by the highest call count
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 elp-sort-by-total-time -- sort by the highest total time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 elp-sort-by-average-time -- sort by the highest average times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 You can write you're own sort function. It should adhere to the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 interface specified by the PRED argument for the `sort' defun. Each
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 \"element of LIST\" is really a 4 element vector where element 0 is
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 the call count, element 1 is the total time spent in the function,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 element 2 is the average time spent in the function, and element 3 is
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
168 the symbol's name string."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
169 :type 'function
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
170 :group 'elp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
172 (defcustom elp-report-limit 1
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 "*Prevents some functions from being displayed in the results buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 If a number, no function that has been called fewer than that number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 of times will be displayed in the output buffer. If nil, all
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
176 functions will be displayed."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
177 :type '(choice integer
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
178 (const :tag "All" nil))
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
179 :group 'elp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
181 (defcustom elp-use-standard-output nil
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
182 "*Non-nil says to output to `standard-output' instead of a buffer."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
183 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
184 :group 'elp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
186 (defcustom elp-recycle-buffers-p t
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 "*Nil says to not recycle the `elp-results-buffer'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 In other words, a new unique buffer is create every time you run
120
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
189 \\[elp-results]."
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
190 :type 'boolean
cca96a509cfe Import from CVS: tag r20-1b12
cvs
parents: 4
diff changeset
191 :group 'elp)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194 ;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 ;; end of user configuration variables
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
198 (defconst elp-version "2.37"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 "ELP version number.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
201 (defconst elp-help-address "tools-help@python.org"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 "Address accepting submissions of bug reports and questions.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 (defvar elp-results-buffer "*ELP Profiling Results*"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 "Buffer name for outputting profiling results.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207 (defconst elp-timer-info-property 'elp-info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 "ELP information property name.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210 (defvar elp-all-instrumented-list nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 "List of all functions currently being instrumented.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 (defvar elp-record-p t
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 "Controls whether functions should record times or not.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 This variable is set by the master function.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 (defvar elp-master nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 "Master function symbol.")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222 (defun elp-instrument-function (funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
223 "Instrument FUNSYM for profiling.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
224 FUNSYM must be a symbol of a defined function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 (interactive "aFunction to instrument: ")
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
226 ;; restore the function. this is necessary to avoid infinite
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
227 ;; recursion of already instrumented functions (i.e. elp-wrapper
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
228 ;; calling elp-wrapper ad infinitum). it is better to simply
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
229 ;; restore the function than to throw an error. this will work
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
230 ;; properly in the face of eval-defun because if the function was
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
231 ;; redefined, only the timer info will be nil'd out since
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
232 ;; elp-restore-function is smart enough not to trash the new
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
233 ;; definition.
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
234 (elp-restore-function funsym)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
235 (let* ((funguts (symbol-function funsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 (infovec (vector 0 0 funguts))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 (newguts '(lambda (&rest args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 ;; we cannot profile macros
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 (and (eq (car-safe funguts) 'macro)
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
240 (error "ELP cannot profile macro: %s" funsym))
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
241 ;; TBD: at some point it might be better to load the autoloaded
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
242 ;; function instead of throwing an error. if we do this, then we
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
243 ;; probably want elp-instrument-package to be updated with the
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
244 ;; newly loaded list of functions. i'm not sure it's smart to do
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
245 ;; the autoload here, since that could have side effects, and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
246 ;; elp-instrument-function is similar (in my mind) to defun-ish
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
247 ;; type functionality (i.e. it shouldn't execute the function).
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
248 (and (eq (car-safe funguts) 'autoload)
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
249 (error "ELP cannot profile autoloaded function: %s" funsym))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 ;; put rest of newguts together
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
251 (if (commandp funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
252 (setq newguts (append newguts '((interactive)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
253 (setq newguts (append newguts (list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
254 (list 'elp-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 (list 'quote funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 (list 'and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 '(interactive-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258 (not (not (commandp funsym))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 'args))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 ;; to record profiling times, we set the symbol's function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 ;; definition so that it runs the elp-wrapper function with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 ;; function symbol as an argument. We place the old function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 ;; definition on the info vector.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 ;; The info vector data structure is a 3 element vector. The 0th
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266 ;; element is the call-count, i.e. the total number of times this
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
267 ;; function has been entered. This value is bumped up on entry to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
268 ;; the function so that non-local exists are still recorded. TBD:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
269 ;; I haven't tested non-local exits at all, so no guarantees.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
270 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
271 ;; The 1st element is the total amount of time in usecs that have
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
272 ;; been spent inside this function. This number is added to on
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
273 ;; function exit.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
274 ;;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
275 ;; The 2nd element is the old function definition list. This gets
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
276 ;; funcall'd in between start/end time retrievals. I believe that
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
277 ;; this lets us profile even byte-compiled functions.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279 ;; put the info vector on the property list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
280 (put funsym elp-timer-info-property infovec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
281
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
282 ;; set the symbol's new profiling function definition to run
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
283 ;; elp-wrapper
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
284 (fset funsym newguts)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 ;; add this function to the instrumentation list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 (or (memq funsym elp-all-instrumented-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 (setq elp-all-instrumented-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289 (cons funsym elp-all-instrumented-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
293 (defun elp-restore-function (funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
294 "Restore an instrumented function to its original definition.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
295 Argument FUNSYM is the symbol of a defined function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
296 (interactive "aFunction to restore: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
297 (let ((info (get funsym elp-timer-info-property)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 ;; delete the function from the all instrumented list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299 (setq elp-all-instrumented-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 (delq funsym elp-all-instrumented-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
302 ;; if the function was the master, reset the master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
303 (if (eq funsym elp-master)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
304 (setq elp-master nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
305 elp-record-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
306
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 ;; zap the properties
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 (put funsym elp-timer-info-property nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ;; restore the original function definition, but if the function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
311 ;; wasn't instrumented do nothing. we do this after the above
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312 ;; because its possible the function got un-instrumented due to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 ;; circumstances beyond our control. Also, check to make sure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314 ;; that the current function symbol points to elp-wrapper. If
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
315 ;; not, then the user probably did an eval-defun, or loaded a
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
316 ;; byte-compiled version, while the function was instrumented and
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
317 ;; we don't want to destroy the new definition. can it ever be
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
318 ;; the case that a lisp function can be compiled instrumented?
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 (and info
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
320 (not (compiled-function-p (symbol-function funsym)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 (assq 'elp-wrapper (symbol-function funsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 (fset funsym (aref info 2)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 (defun elp-instrument-list (&optional list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 "Instrument for profiling, all functions in `elp-function-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 Use optional LIST if provided instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328 (interactive "PList of functions to instrument: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 (let ((list (or list elp-function-list)))
4
b82b59fe008d Import from CVS: tag r19-15b3
cvs
parents: 0
diff changeset
330 (mapcar 'elp-instrument-function list)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 (defun elp-instrument-package (prefix)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 "Instrument for profiling, all functions which start with PREFIX.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 For example, to instrument all ELP functions, do the following:
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 \\[elp-instrument-package] RET elp- RET"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 (interactive "sPrefix of package to instrument: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 (elp-instrument-list
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 (mapcar 'intern (all-completions prefix obarray
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 (lambda (sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 (and (fboundp sym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
344 (not (eq (car-safe
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 (symbol-function sym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 'macro)))))))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
348 (defun elp-restore-list (&optional list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 "Restore the original definitions for all functions in `elp-function-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 Use optional LIST if provided instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351 (interactive "PList of functions to restore: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
352 (let ((list (or list elp-function-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
353 (mapcar 'elp-restore-function list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
354
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
355 (defun elp-restore-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
356 "Restores the original definitions of all functions being profiled."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
358 (elp-restore-list elp-all-instrumented-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
360
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
361 (defun elp-reset-function (funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
362 "Reset the profiling information for FUNSYM."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
363 (interactive "aFunction to reset: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
364 (let ((info (get funsym elp-timer-info-property)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
365 (or info
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 (error "%s is not instrumented for profiling." funsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 (aset info 0 0) ;reset call counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368 (aset info 1 0.0) ;reset total time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
369 ;; don't muck with aref 2 as that is the old symbol definition
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
370 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
371
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
372 (defun elp-reset-list (&optional list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373 "Reset the profiling information for all functions in `elp-function-list'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
374 Use optional LIST if provided instead."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
375 (interactive "PList of functions to reset: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
376 (let ((list (or list elp-function-list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 (mapcar 'elp-reset-function list)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 (defun elp-reset-all ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
380 "Reset the profiling information for all functions being profiled."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
381 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
382 (elp-reset-list elp-all-instrumented-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
383
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 (defun elp-set-master (funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 "Set the master function for profiling."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 (interactive "aMaster function: ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 ;; when there's a master function, recording is turned off by
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
388 ;; default
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389 (setq elp-master funsym
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
390 elp-record-p nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
391 ;; make sure master function is instrumented
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 (or (memq funsym elp-all-instrumented-list)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
393 (elp-instrument-function funsym)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
394
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
395 (defun elp-unset-master ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
396 "Unsets the master function."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
397 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
398 ;; when there's no master function, recording is turned on by default.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
399 (setq elp-master nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400 elp-record-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
401
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
402
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
403 (defsubst elp-get-time ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
404 ;; get current time in seconds and microseconds. I throw away the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405 ;; most significant 16 bits of seconds since I doubt we'll ever want
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 ;; to profile lisp on the order of 18 hours. See notes at top of file.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
407 (let ((now (current-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 (+ (float (nth 1 now)) (/ (float (nth 2 now)) 1000000.0))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 (defun elp-wrapper (funsym interactive-p args)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 "This function has been instrumented for profiling by the ELP.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
412 ELP is the Emacs Lisp Profiler. To restore the function to its
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413 original definition, use \\[elp-restore-function] or \\[elp-restore-all]."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
414 ;; turn on recording if this is the master function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
415 (if (and elp-master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
416 (eq funsym elp-master))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
417 (setq elp-record-p t))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
418 ;; get info vector and original function symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
419 (let* ((info (get funsym elp-timer-info-property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
420 (func (aref info 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421 result)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
422 (or func
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 (error "%s is not instrumented for profiling." funsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
424 (if (not elp-record-p)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
425 ;; when not recording, just call the original function symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
426 ;; and return the results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
427 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
428 (if interactive-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
429 (call-interactively func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
430 (apply func args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
431 ;; we are recording times
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
432 (let ((enter-time (elp-get-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
433 ;; increment the call-counter
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
434 (aset info 0 (1+ (aref info 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
435 ;; now call the old symbol function, checking to see if it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
436 ;; should be called interactively. make sure we return the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
437 ;; correct value
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
438 (setq result
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 (if interactive-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 (call-interactively func)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 (apply func args)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442 ;; calculate total time in function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
443 (aset info 1 (+ (aref info 1) (- (elp-get-time) enter-time)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
444 ))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445 ;; turn off recording if this is the master function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
446 (if (and elp-master
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
447 (eq funsym elp-master))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
448 (setq elp-record-p nil))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
449 result))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 ;; shut the byte-compiler up
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
453 (defvar elp-field-len nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 (defvar elp-cc-len nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 (defvar elp-at-len nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 (defvar elp-et-len nil)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
457
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 (defun elp-sort-by-call-count (vec1 vec2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
459 ;; sort by highest call count. See `sort'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
460 (>= (aref vec1 0) (aref vec2 0)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
461
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
462 (defun elp-sort-by-total-time (vec1 vec2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 ;; sort by highest total time spent in function. See `sort'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 (>= (aref vec1 1) (aref vec2 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
466 (defun elp-sort-by-average-time (vec1 vec2)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 ;; sort by highest average time spent in function. See `sort'.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
468 (>= (aref vec1 2) (aref vec2 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
470 (defsubst elp-pack-number (number width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 ;; pack the NUMBER string into WIDTH characters, watching out for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 ;; very small or large numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 (if (<= (length number) width)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 ;; check for very large or small numbers
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476 (if (string-match "^\\(.*\\)\\(e[+-].*\\)$" number)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
477 (concat (substring
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
478 (substring number (match-beginning 1) (match-end 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 (- width (match-end 2) (- (match-beginning 2)) 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 "..."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 (substring number (match-beginning 2) (match-end 2)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 (concat (substring number 0 width)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 (defun elp-output-result (resultvec)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 ;; output the RESULTVEC into the results buffer. RESULTVEC is a 4 or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 ;; more element vector where aref 0 is the call count, aref 1 is the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 ;; total time spent in the function, aref 2 is the average time
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 ;; spent in the function, and aref 3 is the symbol's string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 ;; name. All other elements in the vector are ignored.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 (let* ((cc (aref resultvec 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 (tt (aref resultvec 1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 (at (aref resultvec 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 (symname (aref resultvec 3))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 callcnt totaltime avetime)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496 (setq callcnt (number-to-string cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 totaltime (number-to-string tt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 avetime (number-to-string at))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 ;; possibly prune the results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 (if (and elp-report-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 (numberp elp-report-limit)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 (< cc elp-report-limit))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 nil
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 (insert symname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
505 (insert-char 32 (+ elp-field-len (- (length symname)) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 ;; print stuff out, formatting it nicely
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
507 (insert callcnt)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 (insert-char 32 (+ elp-cc-len (- (length callcnt)) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
509 (let ((ttstr (elp-pack-number totaltime elp-et-len))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 (atstr (elp-pack-number avetime elp-at-len)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
511 (insert ttstr)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 (insert-char 32 (+ elp-et-len (- (length ttstr)) 2))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 (insert atstr))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 (insert "\n"))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
517 (defun elp-results ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 "Display current profiling results.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 If `elp-reset-after-results' is non-nil, then current profiling
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
520 information for all instrumented functions are reset after results are
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521 displayed."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
523 (let ((curbuf (current-buffer))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524 (resultsbuf (if elp-recycle-buffers-p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
525 (get-buffer-create elp-results-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 (generate-new-buffer elp-results-buffer))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
527 (set-buffer resultsbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
528 (erase-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 (beginning-of-buffer)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 ;; get the length of the longest function name being profiled
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531 (let* ((longest 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
532 (title "Function Name")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
533 (titlelen (length title))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
534 (elp-field-len titlelen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
535 (cc-header "Call Count")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
536 (elp-cc-len (length cc-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
537 (et-header "Elapsed Time")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
538 (elp-et-len (length et-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
539 (at-header "Average Time")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
540 (elp-at-len (length at-header))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
541 (resvec
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
542 (mapcar
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
543 (function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
544 (lambda (funsym)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
545 (let* ((info (get funsym elp-timer-info-property))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
546 (symname (format "%s" funsym))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
547 (cc (aref info 0))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
548 (tt (aref info 1)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
549 (if (not info)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
550 (insert "No profiling information found for: "
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
551 symname)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
552 (setq longest (max longest (length symname)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
553 (vector cc tt (if (zerop cc)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
554 0.0 ;avoid arithmetic div-by-zero errors
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
555 (/ (float tt) (float cc)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
556 symname)))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
557 elp-all-instrumented-list))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
558 ) ; end let*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
559 (insert title)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
560 (if (> longest titlelen)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
561 (progn
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
562 (insert-char 32 (- longest titlelen))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
563 (setq elp-field-len longest)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
564 (insert " " cc-header " " et-header " " at-header "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
565 (insert-char ?= elp-field-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
566 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
567 (insert-char ?= elp-cc-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
568 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
569 (insert-char ?= elp-et-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
570 (insert " ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
571 (insert-char ?= elp-at-len)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
572 (insert "\n")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
573 ;; if sorting is enabled, then sort the results list. in either
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
574 ;; case, call elp-output-result to output the result in the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
575 ;; buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
576 (if elp-sort-by-function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
577 (setq resvec (sort resvec elp-sort-by-function)))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
578 (mapcar 'elp-output-result resvec))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
579 ;; now pop up results buffer
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
580 (set-buffer curbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
581 (pop-to-buffer resultsbuf)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
582 ;; copy results to standard-output?
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
583 (if (or elp-use-standard-output noninteractive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
584 (princ (buffer-substring (point-min) (point-max))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
585 ;; reset profiling info if desired
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
586 (and elp-reset-after-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
587 (elp-reset-all))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
588
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
589
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
590 (eval-when-compile
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
591 (require 'reporter))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
592
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
593 ;;;###autoload
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
594 (defun elp-submit-bug-report ()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
595 "Submit via mail, a bug report on elp."
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
596 (interactive)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
597 (and
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
598 (y-or-n-p "Do you want to submit a report on elp? ")
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
599 (require 'reporter)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
600 (reporter-submit-bug-report
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
601 elp-help-address (concat "elp " elp-version)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
602 '(elp-report-limit
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
603 elp-reset-after-results
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
604 elp-sort-by-function))))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
605
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
606
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
607 (provide 'elp)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
608 ;; elp.el ends here