;;; elp.el --- Emacs Lisp Profiler
-;; Copyright (C) 1994 Free Software Foundation, Inc.
+;; Copyright (C) 1994, 1995, 1997 Free Software Foundation, Inc.
;; Author: 1994-1997 Barry A. Warsaw
;; Maintainer: tools-help@python.org
;; Created: 26-Feb-1994
-;; Version: 2.39
-;; Last Modified: 1997/02/28 18:15:35
+;; Version: 3.0
+;; Last Modified: 1997/04/21 17:45:15
;; Keywords: debugging lisp tools
;; This file is part of GNU Emacs.
;; elp-restore-function. The other instrument, restore, and reset
;; functions are provided for symmetry.
-;; Note that there are plenty of factors that could make the times
-;; reported unreliable, including the accuracy and granularity of your
-;; system clock, and the overhead spent in lisp calculating and
-;; recording the intervals. The latter I figure is pretty constant
-;; so, while the times may not be entirely accurate, I think they'll
-;; give you a good feel for the relative amount of work spent in the
-;; various lisp routines you are profiling. Note further that times
-;; are calculated using wall-clock time, so other system load will
-;; affect accuracy too.
-
;; Here is a list of variable you can use to customize elp:
;; elp-function-list
;; elp-reset-after-results
;;; Background:
-;; This program is based on the only two existing Emacs Lisp profilers
-;; that I'm aware of, Boaz Ben-Zvi's profile.el, and Root Boy Jim's
-;; profiler.el. Both were written for Emacs 18 and both were pretty
-;; good first shots at profiling, but I found that they didn't provide
-;; the functionality or interface that I wanted. So I wrote this.
-;; I've tested elp in Emacs 19 and in XEmacs. There's no point in
-;; even trying to make this work with Emacs 18.
+;; This program was inspired by the only two existing Emacs Lisp
+;; profilers that I'm aware of, Boaz Ben-Zvi's profile.el, and Root
+;; Boy Jim's profiler.el. Both were written for Emacs 18 and both were
+;; pretty good first shots at profiling, but I found that they didn't
+;; provide the functionality or interface that I wanted, so I wrote
+;; this. I've tested elp in XEmacs 19 and Emacs 19. There's no point
+;; in even trying to make this work with Emacs 18.
;; Unlike previous profilers, elp uses Emacs 19's built-in function
;; current-time to return interval times. This obviates the need for
;;; Code:
\f
-;; start user configuration variables
+;; start of user configuration variables
;; vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
-(defvar elp-function-list nil
- "*List of function to profile.
-Used by the command `elp-instrument-list'.")
+(defgroup elp nil
+ "Emacs Lisp Profiler"
+ :group 'lisp)
+
+(defcustom elp-function-list nil
+ "*List of functions to profile.
+Used by the command `elp-instrument-list'."
+ :type '(repeat function)
+ :group 'elp)
-(defvar elp-reset-after-results t
+(defcustom elp-reset-after-results t
"*Non-nil means reset all profiling info after results are displayed.
-Results are displayed with the `elp-results' command.")
+Results are displayed with the `elp-results' command."
+ :type 'boolean
+ :group 'elp)
-(defvar elp-sort-by-function 'elp-sort-by-total-time
+(defcustom elp-sort-by-function 'elp-sort-by-total-time
"*Non-nil specifies elp results sorting function.
These functions are currently available:
\"element of LIST\" is really a 4 element vector where element 0 is
the call count, element 1 is the total time spent in the function,
element 2 is the average time spent in the function, and element 3 is
-the symbol's name string.")
+the symbol's name string."
+ :type 'function
+ :group 'elp)
-(defvar elp-report-limit 1
+(defcustom elp-report-limit 1
"*Prevents some functions from being displayed in the results buffer.
If a number, no function that has been called fewer than that number
of times will be displayed in the output buffer. If nil, all
-functions will be displayed.")
+functions will be displayed."
+ :type '(choice integer
+ (const :tag "Show All" nil))
+ :group 'elp)
-(defvar elp-use-standard-output nil
- "*Non-nil says to output to `standard-output' instead of a buffer.")
+(defcustom elp-use-standard-output nil
+ "*Non-nil says to output to `standard-output' instead of a buffer."
+ :type 'boolean
+ :group 'elp)
-(defvar elp-recycle-buffers-p t
+(defcustom elp-recycle-buffers-p t
"*Nil says to not recycle the `elp-results-buffer'.
In other words, a new unique buffer is create every time you run
-\\[elp-results].")
+\\[elp-results]."
+ :type 'boolean
+ :group 'elp)
;; ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
;; end of user configuration variables
\f
-(defconst elp-version "2.39"
+(defconst elp-version "3.0"
"ELP version number.")
(defconst elp-help-address "tools-help@python.org"
(defvar elp-master nil
"Master function symbol.")
+\f
;;;###autoload
(defun elp-instrument-function (funsym)
"Instrument FUNSYM for profiling.
\\[elp-instrument-package] RET elp- RET"
(interactive "sPrefix of package to instrument: ")
(elp-instrument-list
- (mapcar 'intern
- (all-completions prefix obarray
- (function
- (lambda (sym)
- (and (fboundp sym)
- (not (memq (car-safe (symbol-function sym))
- '(autoload macro))))))))))
+ (mapcar
+ 'intern
+ (all-completions
+ prefix obarray
+ (function
+ (lambda (sym)
+ (and (fboundp sym)
+ (not (memq (car-safe (symbol-function sym)) '(autoload macro))))
+ ))
+ ))))
(defun elp-restore-list (&optional list)
"Restore the original definitions for all functions in `elp-function-list'.
'(elp-report-limit
elp-reset-after-results
elp-sort-by-function))))
-
\f
(provide 'elp)