• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.9.5/emacs-92/emacs/lisp/emacs-lisp/

Lines Matching refs:elp

0 ;;; elp.el --- Emacs Lisp Profiler
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
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
39 ;; elp-reset-all.
43 ;; prefix. Use M-x elp-instrument-package for this.
45 ;; If you want to sort the results, set elp-sort-by-function to some
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
50 ;; by setting elp-report-limit.
55 ;; re-instrument it with M-x elp-instrument-function. This will also
71 ;; elp-set-master and M-x elp-unset-master to utilize this feature.
75 ;; elp-restore-function. The other instrument, restore, and reset
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
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
115 ;; this. I've tested elp in XEmacs 19 and Emacs 19. There's no point
118 ;; Unlike previous profilers, elp uses Emacs 19's built-in function
134 (defgroup elp nil
138 (defcustom elp-function-list nil
140 Used by the command `elp-instrument-list'."
142 :group 'elp)
144 (defcustom elp-reset-after-results t
146 Results are displayed with the `elp-results' command."
148 :group 'elp)
150 (defcustom elp-sort-by-function 'elp-sort-by-total-time
151 "*Non-nil specifies elp results sorting function.
154 elp-sort-by-call-count -- sort by the highest call count
155 elp-sort-by-total-time -- sort by the highest total time
156 elp-sort-by-average-time -- sort by the highest average times
165 :group 'elp)
167 (defcustom elp-report-limit 1
174 :group 'elp)
176 (defcustom elp-use-standard-output nil
179 :group 'elp)
181 (defcustom elp-recycle-buffers-p t
182 "*nil says to not recycle the `elp-results-buffer'.
184 \\[elp-results]."
186 :group 'elp)
194 (defvar elp-results-buffer "*ELP Profiling Results*"
197 (defconst elp-timer-info-property 'elp-info
200 (defvar elp-all-instrumented-list nil
203 (defvar elp-record-p t
207 (defvar elp-master nil
210 (defvar elp-not-profilable
212 '(elp-wrapper called-interactively-p
215 ;; (aref (symbol-function 'elp-wrapper) 2)))
222 (defun elp-profilable-p (fun)
225 (not (or (memq fun elp-not-profilable)
237 (defun elp-instrument-function (funsym)
242 ;; recursion of already instrumented functions (i.e. elp-wrapper
243 ;; calling elp-wrapper ad infinitum). it is better to simply
247 ;; elp-restore-function is smart enough not to trash the new
249 (elp-restore-function funsym)
258 ;; probably want elp-instrument-package to be updated with the
261 ;; elp-instrument-function is similar (in my mind) to defun-ish
266 (unless (elp-profilable-p funsym)
271 (setq newguts (append newguts `((elp-wrapper
277 ;; definition so that it runs the elp-wrapper function with the
296 (put funsym elp-timer-info-property infovec)
299 ;; elp-wrapper.
311 (unless (memq funsym elp-all-instrumented-list)
312 (push funsym elp-all-instrumented-list))))
314 (defun elp-restore-function (funsym)
318 (let ((info (get funsym elp-timer-info-property)))
320 (setq elp-all-instrumented-list
321 (delq funsym elp-all-instrumented-list))
324 (if (eq funsym elp-master)
325 (setq elp-master nil
326 elp-record-p t))
329 (put funsym elp-timer-info-property nil)
335 ;; that the current function symbol points to elp-wrapper. If
343 (assq 'elp-wrapper (symbol-function funsym))
347 (defun elp-instrument-list (&optional list)
348 "Instrument for profiling, all functions in `elp-function-list'.
351 (let ((list (or list elp-function-list)))
352 (mapcar 'elp-instrument-function list)))
355 (defun elp-instrument-package (prefix)
359 \\[elp-instrument-package] RET elp- RET"
362 obarray 'elp-profilable-p)))
365 (elp-instrument-list
368 (all-completions prefix obarray 'elp-profilable-p))))
370 (defun elp-restore-list (&optional list)
371 "Restore the original definitions for all functions in `elp-function-list'.
374 (let ((list (or list elp-function-list)))
375 (mapcar 'elp-restore-function list)))
377 (defun elp-restore-all ()
380 (elp-restore-list elp-all-instrumented-list))
384 (defun elp-reset-function (funsym)
387 (let ((info (get funsym elp-timer-info-property)))
395 (defun elp-reset-list (&optional list)
396 "Reset the profiling information for all functions in `elp-function-list'.
399 (let ((list (or list elp-function-list)))
400 (mapcar 'elp-reset-function list)))
402 (defun elp-reset-all ()
405 (elp-reset-list elp-all-instrumented-list))
407 (defun elp-set-master (funsym)
412 (setq elp-master funsym
413 elp-record-p nil)
415 (or (memq funsym elp-all-instrumented-list)
416 (elp-instrument-function funsym)))
418 (defun elp-unset-master ()
422 (setq elp-master nil
423 elp-record-p t))
427 (defsubst elp-elapsed-time (start end)
432 (defun elp-wrapper (funsym interactive-p args)
435 original definition, use \\[elp-restore-function] or \\[elp-restore-all]."
437 (if (and elp-master
438 (eq funsym elp-master))
439 (setq elp-record-p t))
441 (let* ((info (get funsym elp-timer-info-property))
446 (if (not elp-record-p)
468 (aset info 1 (+ (aref info 1) (elp-elapsed-time enter-time exit-time)))
471 (if (and elp-master
472 (eq funsym elp-master))
473 (setq elp-record-p nil))
479 (defvar elp-field-len nil)
480 (defvar elp-cc-len nil)
481 (defvar elp-at-len nil)
482 (defvar elp-et-len nil)
484 (defun elp-sort-by-call-count (vec1 vec2)
488 (defun elp-sort-by-total-time (vec1 vec2)
492 (defun elp-sort-by-average-time (vec1 vec2)
496 (defsubst elp-pack-number (number width)
511 (defun elp-output-result (resultvec)
526 (if (and elp-report-limit
527 (numberp elp-report-limit)
528 (< cc elp-report-limit))
530 (elp-output-insert-symname symname)
531 (insert-char 32 (+ elp-field-len (- (length symname)) 2))
534 (insert-char 32 (+ elp-cc-len (- (length callcnt)) 2))
535 (let ((ttstr (elp-pack-number totaltime elp-et-len))
536 (atstr (elp-pack-number avetime elp-at-len)))
538 (insert-char 32 (+ elp-et-len (- (length ttstr)) 2))
542 (defvar elp-results-symname-map
544 (define-key map [mouse-2] 'elp-results-jump-to-definition)
545 (define-key map "\C-m" 'elp-results-jump-to-definition)
549 (defun elp-results-jump-to-definition (&optional event)
553 (find-function (get-text-property (point) 'elp-symname)))
555 (defun elp-output-insert-symname (symname)
558 'elp-symname (intern symname)
559 'keymap elp-results-symname-map
564 (defun elp-results ()
566 If `elp-reset-after-results' is non-nil, then current profiling
571 (resultsbuf (if elp-recycle-buffers-p
572 (get-buffer-create elp-results-buffer)
573 (generate-new-buffer elp-results-buffer))))
580 (elp-field-len titlelen)
582 (elp-cc-len (length cc-header))
584 (elp-et-len (length et-header))
586 (elp-at-len (length at-header))
591 (let* ((info (get funsym elp-timer-info-property))
603 elp-all-instrumented-list))
609 (setq elp-field-len longest)))
611 (insert-char ?= elp-field-len)
613 (insert-char ?= elp-cc-len)
615 (insert-char ?= elp-et-len)
617 (insert-char ?= elp-at-len)
620 ;; case, call elp-output-result to output the result in the
622 (if elp-sort-by-function
623 (setq resvec (sort resvec elp-sort-by-function)))
624 (mapcar 'elp-output-result resvec))
629 (if (or elp-use-standard-output noninteractive)
632 (and elp-reset-after-results
633 (elp-reset-all))))
635 (defun elp-unload-hook ()
636 (elp-restore-all))
637 (add-hook 'elp-unload-hook 'elp-unload-hook)
640 (provide 'elp)
643 ;;; elp.el ends here