mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-01-05 11:21:04 -08:00
(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.
This commit is contained in:
parent
8ea231fcac
commit
5fe4899af7
1 changed files with 46 additions and 22 deletions
|
|
@ -1,12 +1,13 @@
|
||||||
;;; elp.el --- Emacs Lisp Profiler
|
;;; elp.el --- Emacs Lisp Profiler
|
||||||
|
|
||||||
|
;; Copyright (C) 1994 Barry A. Warsaw
|
||||||
;; Copyright (C) 1994 Free Software Foundation, Inc.
|
;; Copyright (C) 1994 Free Software Foundation, Inc.
|
||||||
|
|
||||||
;; Author: 1994 Barry A. Warsaw <bwarsaw@cnri.reston.va.us>
|
;; Author: 1994 Barry A. Warsaw <bwarsaw@cnri.reston.va.us>
|
||||||
;; Maintainer: tools-help@anthem.nlm.nih.gov
|
;; Maintainer: tools-help@anthem.nlm.nih.gov
|
||||||
;; Created: 26-Feb-1994
|
;; Created: 26-Feb-1994
|
||||||
;; Version: 2.18
|
;; Version: 2.22
|
||||||
;; Last Modified: 1994/09/14 14:00:09
|
;; Last Modified: 1994/12/23 17:46:21
|
||||||
;; Keywords: Emacs Lisp Profile Timing
|
;; Keywords: Emacs Lisp Profile Timing
|
||||||
|
|
||||||
;; This file is part of GNU Emacs.
|
;; This file is part of GNU Emacs.
|
||||||
|
|
@ -32,8 +33,8 @@
|
||||||
;; profiler.el. Both were written for Emacs 18 and both were pretty
|
;; 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
|
;; good first shots at profiling, but I found that they didn't provide
|
||||||
;; the functionality or interface that I wanted. So I wrote this.
|
;; the functionality or interface that I wanted. So I wrote this.
|
||||||
;; I've tested elp in Lucid Emacs 19.9 and Emacs 19.22. There's no
|
;; I've tested elp in both Emacs 19's. There's no point in even
|
||||||
;; point in even trying to make this work with Emacs 18.
|
;; trying to make this work with Emacs 18.
|
||||||
|
|
||||||
;; Unlike previous profilers, elp uses Emacs 19's built-in function
|
;; Unlike previous profilers, elp uses Emacs 19's built-in function
|
||||||
;; current-time to return interval times. This obviates the need for
|
;; current-time to return interval times. This obviates the need for
|
||||||
|
|
@ -54,8 +55,11 @@
|
||||||
;; are calculated using wall-clock time, so other system load will
|
;; are calculated using wall-clock time, so other system load will
|
||||||
;; affect accuracy too.
|
;; affect accuracy too.
|
||||||
|
|
||||||
;; There are only 3 variables you can change to customize behavior of
|
;; Here is a list of variable you can use to customize elp:
|
||||||
;; elp. See below for their description.
|
;; elp-function-list
|
||||||
|
;; elp-reset-after-results
|
||||||
|
;; elp-sort-by-function
|
||||||
|
;; elp-report-limit
|
||||||
;;
|
;;
|
||||||
;; Here is a list of the interactive commands you can use:
|
;; Here is a list of the interactive commands you can use:
|
||||||
;; elp-instrument-function
|
;; elp-instrument-function
|
||||||
|
|
@ -67,6 +71,8 @@
|
||||||
;; elp-reset-function
|
;; elp-reset-function
|
||||||
;; elp-reset-list
|
;; elp-reset-list
|
||||||
;; elp-reset-all
|
;; elp-reset-all
|
||||||
|
;; elp-set-master
|
||||||
|
;; elp-unset-master
|
||||||
;; elp-results
|
;; elp-results
|
||||||
;; elp-submit-bug-report
|
;; elp-submit-bug-report
|
||||||
;;
|
;;
|
||||||
|
|
@ -76,12 +82,12 @@
|
||||||
;; information is recorded whenever they are called. To print out the
|
;; information is recorded whenever they are called. To print out the
|
||||||
;; current results, use elp-results. With elp-reset-after-results set
|
;; current results, use elp-results. With elp-reset-after-results set
|
||||||
;; to non-nil, profiling information will be reset whenever the
|
;; to non-nil, profiling information will be reset whenever the
|
||||||
;; results are displayed. You can also reset all profiling info at any
|
;; results are displayed. You can also reset all profiling info at
|
||||||
;; time with elp-reset-all.
|
;; any time with elp-reset-all.
|
||||||
;;
|
;;
|
||||||
;; You can also instrument all functions in a package, provided that
|
;; You can also instrument all functions in a package, provided that
|
||||||
;; the package follows the GNU coding standard of a common textural
|
;; the package follows the GNU coding standard of a common textural
|
||||||
;; prefix. elp-instrument-package does this.
|
;; prefix. Use the elp-instrument-package command for this.
|
||||||
;;
|
;;
|
||||||
;; If you want to sort the results, set elp-sort-by-function to some
|
;; If you want to sort the results, set elp-sort-by-function to some
|
||||||
;; predicate function. The three most obvious choices are predefined:
|
;; predicate function. The three most obvious choices are predefined:
|
||||||
|
|
@ -92,8 +98,8 @@
|
||||||
;;
|
;;
|
||||||
;; Elp can instrument byte-compiled functions just as easily as
|
;; Elp can instrument byte-compiled functions just as easily as
|
||||||
;; interpreted functions, but it cannot instrument macros. However,
|
;; interpreted functions, but it cannot instrument macros. However,
|
||||||
;; when you redefine a function (e.g. with eval-defun), you'll need
|
;; when you redefine a function (e.g. with eval-defun), you'll need to
|
||||||
;; to re-instrument it with elp-instrument-function. Re-instrumenting
|
;; re-instrument it with elp-instrument-function. Re-instrumenting
|
||||||
;; resets profiling information for that function. Elp can also
|
;; resets profiling information for that function. Elp can also
|
||||||
;; handle interactive functions (i.e. commands), but of course any
|
;; handle interactive functions (i.e. commands), but of course any
|
||||||
;; time spent idling for user prompts will show up in the timing
|
;; time spent idling for user prompts will show up in the timing
|
||||||
|
|
@ -108,8 +114,8 @@
|
||||||
;; (defun baz () (bar) (foo))
|
;; (defun baz () (bar) (foo))
|
||||||
;;
|
;;
|
||||||
;; and you want to find out the amount of time spent in bar and foo,
|
;; and you want to find out the amount of time spent in bar and foo,
|
||||||
;; but only during execution of bar, make bar the master and the call
|
;; but only during execution of bar, make bar the master. The call of
|
||||||
;; of foo from baz will not add to foo's total timing sums. Use
|
;; foo from baz will not add to foo's total timing sums. Use
|
||||||
;; elp-set-master and elp-unset-master to utilize this feature. Only
|
;; elp-set-master and elp-unset-master to utilize this feature. Only
|
||||||
;; one master function can be used at a time.
|
;; one master function can be used at a time.
|
||||||
|
|
||||||
|
|
@ -117,6 +123,11 @@
|
||||||
;; elp-restore-function. The other instrument, restore, and reset
|
;; elp-restore-function. The other instrument, restore, and reset
|
||||||
;; functions are provided for symmetry.
|
;; functions are provided for symmetry.
|
||||||
|
|
||||||
|
;; LCD Archive Entry:
|
||||||
|
;; elp|Barry A. Warsaw|tools-help@anthem.nlm.nih.gov|
|
||||||
|
;; Emacs Lisp Profiler|
|
||||||
|
;; 1994/12/23 17:46:21|2.22|~/misc/elp.el.Z|
|
||||||
|
|
||||||
;;; Code:
|
;;; Code:
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -156,7 +167,7 @@ functions will be displayed.")
|
||||||
;; end user configuration variables
|
;; end user configuration variables
|
||||||
|
|
||||||
|
|
||||||
(defconst elp-version "2.18"
|
(defconst elp-version "2.22"
|
||||||
"ELP version number.")
|
"ELP version number.")
|
||||||
|
|
||||||
(defconst elp-help-address "tools-help@anthem.nlm.nih.gov"
|
(defconst elp-help-address "tools-help@anthem.nlm.nih.gov"
|
||||||
|
|
@ -336,6 +347,7 @@ Use optional LIST if provided instead."
|
||||||
|
|
||||||
(defun elp-unset-master ()
|
(defun elp-unset-master ()
|
||||||
"Unsets the master function."
|
"Unsets the master function."
|
||||||
|
(interactive)
|
||||||
;; when there's no master function, recording is turned on by default.
|
;; when there's no master function, recording is turned on by default.
|
||||||
(setq elp-master nil
|
(setq elp-master nil
|
||||||
elp-record-p t))
|
elp-record-p t))
|
||||||
|
|
@ -408,6 +420,21 @@ original definition, use \\[elp-restore-function] or \\[elp-restore-all]."
|
||||||
;; sort by highest average time spent in function. See `sort'.
|
;; sort by highest average time spent in function. See `sort'.
|
||||||
(>= (aref vec1 2) (aref vec2 2)))
|
(>= (aref vec1 2) (aref vec2 2)))
|
||||||
|
|
||||||
|
(defsubst elp-pack-number (number width)
|
||||||
|
;; pack the NUMBER string into WIDTH characters, watching out for
|
||||||
|
;; very small or large numbers
|
||||||
|
(if (<= (length number) width)
|
||||||
|
number
|
||||||
|
;; check for very large or small numbers
|
||||||
|
(if (string-match "^\\(.*\\)\\(e[+-].*\\)$" number)
|
||||||
|
(concat (substring
|
||||||
|
(substring number (match-beginning 1) (match-end 1))
|
||||||
|
0
|
||||||
|
(- width (match-end 2) (- (match-beginning 2)) 3))
|
||||||
|
"..."
|
||||||
|
(substring number (match-beginning 2) (match-end 2)))
|
||||||
|
(concat (substring number 0 width)))))
|
||||||
|
|
||||||
(defun elp-output-result (resultvec)
|
(defun elp-output-result (resultvec)
|
||||||
;; output the RESULTVEC into the results buffer. RESULTVEC is a 4 or
|
;; output the RESULTVEC into the results buffer. RESULTVEC is a 4 or
|
||||||
;; more element vector where aref 0 is the call count, aref 1 is the
|
;; 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]."
|
||||||
;; print stuff out, formatting it nicely
|
;; print stuff out, formatting it nicely
|
||||||
(insert callcnt)
|
(insert callcnt)
|
||||||
(insert-char 32 (+ elp-cc-len (- (length callcnt)) 2))
|
(insert-char 32 (+ elp-cc-len (- (length callcnt)) 2))
|
||||||
(if (> (length totaltime) elp-et-len)
|
(let ((ttstr (elp-pack-number totaltime elp-et-len))
|
||||||
(insert (substring totaltime 0 elp-et-len) " ")
|
(atstr (elp-pack-number avetime elp-at-len)))
|
||||||
(insert totaltime)
|
(insert ttstr)
|
||||||
(insert-char 32 (+ elp-et-len (- (length totaltime)) 2)))
|
(insert-char 32 (+ elp-et-len (- (length ttstr)) 2))
|
||||||
(if (> (length avetime) elp-at-len)
|
(insert atstr))
|
||||||
(insert (substring avetime 0 elp-at-len))
|
|
||||||
(insert avetime))
|
|
||||||
(insert "\n"))))
|
(insert "\n"))))
|
||||||
|
|
||||||
;;;###autoload
|
;;;###autoload
|
||||||
|
|
@ -528,5 +553,4 @@ displayed."
|
||||||
|
|
||||||
|
|
||||||
(provide 'elp)
|
(provide 'elp)
|
||||||
|
|
||||||
;; elp.el ends here
|
;; elp.el ends here
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue