home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / editors / emacs / xemacs / xemacs-1.006 / xemacs-1 / lib / xemacs-19.13 / lisp / utils / elp.el < prev    next >
Encoding:
Text File  |  1995-07-14  |  21.0 KB  |  586 lines

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