Mercurial > emacs
annotate lisp/emacs-lisp/benchmark.el @ 104444:2bf481006ba4
lisp/Makefile.in: Ignore CEDET subdirectories when making subdirs.el.
lisp/emacs-lisp/autoload.el (generated-autoload-feature): New var.
(autoload-rubric): Use it.
lisp/cedet/semantic/adebug.el (data-debug-insert-find-results-button): Require
db-find.
lisp/cedet/semantic/analyze.el: Require semantic/tag. Don't declare
autoloaded functions.
lisp/cedet/semantic/chart.el: Don't declare autoloaded functions.
lisp/cedet/semantic/complete.el: eval-when-compile semantic/find for macro.
(semantic-collector-calculate-completions-raw): Require semantic/db-find.
lisp/cedet/semantic/ctxt.el (semantic-up-context): Require semantic/find.
Don't require it at top-level.
lisp/cedet/semantic/db-ebrowse.el (semanticdb-ebrowse-dump): Require
data-debug. Don't require it at top-level. Don't require semantic/sort.
lisp/cedet/semantic/db-find.el: Add local vars for autoloading.
Don't require semantic/tag-file and semantic/sort.
(semanticdb-find-default-throttle, semanticdb-find-result-length)
(semanticdb-find-result-nth, semanticdb-find-result-nth-in-buffer)
(semanticdb-find-tags-by-name, semanticdb-find-tags-for-completion)
(semanticdb-find-translate-path, semanticdb-find-table-for-include): Autoload.
lisp/cedet/semantic/db-ref.el: Require semantic and semantic/tag.
(semanticdb-ref-test): Require data-debug. Don't require it at
top-level.
lisp/cedet/semantic/db-typecache.el: Require semantic and semantic/tag.
Declare semantic-sort-tags-by-name-then-type-increasing and
semantic-scope-tag-clone-with-scope.
eval-when-compile semantic/find for semantic-find-tags-by-* macros.
Add local vars for autoloading.
(semanticdb-typecache-find): Autoload.
lisp/cedet/semantic/db.el: Add local vars for autoloading.
(semanticdb-current-database, semanticdb-current-table)
(semanticdb-file-table-object): Autoload.
lisp/cedet/semantic/decorate.el: Don't requirements for autoloaded functions.
lisp/cedet/semantic/doc.el: Add local vars for autoloading.
(semantic-documentation-for-tag): Autoload.
lisp/cedet/semantic/edit.el: Drop requirements for autoloaded functions.
lisp/cedet/semantic/find.el: Add local vars for autoloading.
(semantic-current-tag, semantic-find-tag-by-overlay)
(semantic-find-first-tag-by-name): Autoload.
lisp/cedet/semantic/format.el: Add local vars for autoloading.
(semantic-format-tag-name, semantic-format-tag-custom-list)
(semantic-format-tag-functions): Autoload.
lisp/cedet/semantic/fw.el: Require semantic/loaddefs.
lisp/cedet/semantic/html.el (semantic-html-recursive-combobulate-list):
Use assoc-string instead of assoc-case.
lisp/cedet/semantic/ia.el (semantic-ia-insert-tag): Move up to avoid
compiler error.
(semantic-ia-complete-symbol-menu): Require imenu.
(semantic-ia-fast-jump): Require semantic/decorate/include.
lisp/cedet/semantic/idle.el: Require semantic and semantic/tag.
Declare semanticdb-typecache-refresh-for-buffer and eldoc-message.
eval-when-compile semantic/find for semantic-find-tags-by-name macro.
lisp/cedet/semantic/sort.el: Add local vars for autoloading.
(semantic-flatten-tags-table, semantic-tag-external-member-parent):
Autoload.
lisp/cedet/semantic/tag-file.el: Add local vars for autoloading.
(semantic-go-to-tag, semantic-dependency-tag-file): Autoload.
lisp/cedet/semantic/tag-ls.el: Add local vars for autoloading.
(semantic-tag-prototype-p): Autoload.
lisp/cedet/semantic/tag.el: Don't declare autoloaded functions.
lisp/cedet/semantic/analyze/complete.el: Add local variables for autoloading.
(semantic-analyze-possible-completions): Autoload.
lisp/cedet/semantic/analyze/fcn.el: Require mode-local.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 02 Sep 2009 04:37:10 +0000 |
parents | ace8aa76b9b5 |
children | 1d1d5d9bd884 |
rev | line source |
---|---|
49574 | 1 ;;; benchmark.el --- support for benchmarking code |
2 | |
100908 | 3 ;; Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
4 ;; Free Software Foundation, Inc. |
49574 | 5 |
6 ;; Author: Dave Love <fx@gnu.org> | |
7 ;; Keywords: lisp, extensions | |
8 | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
9 ;; This file is part of GNU Emacs. |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
10 |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
11 ;; GNU Emacs is free software: you can redistribute it and/or modify |
49574 | 12 ;; it under the terms of the GNU General Public License as published by |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
13 ;; the Free Software Foundation, either version 3 of the License, or |
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
14 ;; (at your option) any later version. |
49574 | 15 |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
16 ;; GNU Emacs is distributed in the hope that it will be useful, |
49574 | 17 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of |
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 ;; GNU General Public License for more details. | |
20 | |
21 ;; You should have received a copy of the GNU General Public License | |
94655
90a2847062be
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
93975
diff
changeset
|
22 ;; along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. |
49574 | 23 |
24 ;;; Commentary: | |
25 | |
26 ;; Utilities for timing the execution of forms, including the time | |
27 ;; taken for GC. Note that prior to timing code you may want to | |
28 ;; ensure things like: there has just been a GC, the relevant code is | |
29 ;; already loaded (so that there's no overhead from autoloading etc.), | |
30 ;; and the code is compiled if appropriate (but see | |
31 ;; `benchmark-run-compiled'). | |
32 | |
33 ;;; Code: | |
34 | |
35 (defmacro benchmark-elapse (&rest forms) | |
36 "Return the time in seconds elapsed for execution of FORMS." | |
37 (let ((t1 (make-symbol "t1")) | |
38 (t2 (make-symbol "t2"))) | |
39 `(let (,t1 ,t2) | |
40 (setq ,t1 (current-time)) | |
41 ,@forms | |
42 (setq ,t2 (current-time)) | |
43 (+ (* (- (car ,t2) (car ,t1)) 65536.0) | |
44 (- (nth 1 ,t2) (nth 1 ,t1)) | |
45 (* (- (nth 2 ,t2) (nth 2 ,t1)) 1.0e-6))))) | |
46 (put 'benchmark-elapse 'edebug-form-spec t) | |
47 (put 'benchmark-elapse 'lisp-indent-function 0) | |
48 | |
49 ;;;###autoload | |
50 (defmacro benchmark-run (&optional repetitions &rest forms) | |
51 "Time execution of FORMS. | |
52 If REPETITIONS is supplied as a number, run forms that many times, | |
53 accounting for the overhead of the resulting loop. Otherwise run | |
54 FORMS once. | |
55 Return a list of the total elapsed time for execution, the number of | |
56 garbage collections that ran, and the time taken by garbage collection. | |
57 See also `benchmark-run-compiled'." | |
58 (unless (natnump repetitions) | |
59 (setq forms (cons repetitions forms) | |
60 repetitions 1)) | |
61 (let ((i (make-symbol "i")) | |
62 (gcs (make-symbol "gcs")) | |
63 (gc (make-symbol "gc"))) | |
64 `(let ((,gc gc-elapsed) | |
65 (,gcs gcs-done)) | |
66 (list ,(if (> repetitions 1) | |
67 ;; Take account of the loop overhead. | |
68 `(- (benchmark-elapse (dotimes (,i ,repetitions) | |
69 ,@forms)) | |
70 (benchmark-elapse (dotimes (,i ,repetitions)))) | |
71 `(benchmark-elapse ,@forms)) | |
72 (- gcs-done ,gcs) | |
73 (- gc-elapsed ,gc))))) | |
74 (put 'benchmark-run 'edebug-form-spec t) | |
75 (put 'benchmark-run 'lisp-indent-function 2) | |
76 | |
77 ;;;###autoload | |
78 (defmacro benchmark-run-compiled (&optional repetitions &rest forms) | |
79 "Time execution of compiled version of FORMS. | |
80 This is like `benchmark-run', but what is timed is a funcall of the | |
81 byte code obtained by wrapping FORMS in a `lambda' and compiling the | |
82 result. The overhead of the `lambda's is accounted for." | |
83 (unless (natnump repetitions) | |
84 (setq forms (cons repetitions forms) | |
85 repetitions 1)) | |
86 (let ((i (make-symbol "i")) | |
87 (gcs (make-symbol "gcs")) | |
88 (gc (make-symbol "gc")) | |
89 (code (byte-compile `(lambda () ,@forms))) | |
90 (lambda-code (byte-compile `(lambda ())))) | |
91 `(let ((,gc gc-elapsed) | |
92 (,gcs gcs-done)) | |
93 (list ,(if (> repetitions 1) | |
94 ;; Take account of the loop overhead. | |
95 `(- (benchmark-elapse (dotimes (,i ,repetitions) | |
96 (funcall ,code))) | |
97 (benchmark-elapse (dotimes (,i ,repetitions) | |
98 (funcall ,lambda-code)))) | |
99 `(benchmark-elapse (funcall ,code))) | |
100 (- gcs-done ,gcs) (- gc-elapsed ,gc))))) | |
101 (put 'benchmark-run-compiled 'edebug-form-spec t) | |
102 (put 'benchmark-run-compiled 'lisp-indent-function 2) | |
103 | |
104 ;;;###autoload | |
105 (defun benchmark (repetitions form) | |
106 "Print the time taken for REPETITIONS executions of FORM. | |
102620
ace8aa76b9b5
* emacs-lisp/benchmark.el (benchmark): Reflow docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
107 Interactively, REPETITIONS is taken from the prefix arg. |
ace8aa76b9b5
* emacs-lisp/benchmark.el (benchmark): Reflow docstring.
Juanma Barranquero <lekktu@gmail.com>
parents:
100908
diff
changeset
|
108 For non-interactive use see also `benchmark-run' and |
49574 | 109 `benchmark-run-compiled'." |
110 (interactive "p\nxForm: ") | |
111 (let ((result (eval `(benchmark-run ,repetitions ,form)))) | |
112 (if (zerop (nth 1 result)) | |
113 (message "Elapsed time: %fs" (car result)) | |
114 (message "Elapsed time: %fs (%fs in %d GCs)" (car result) | |
115 (nth 2 result) (nth 1 result))))) | |
116 | |
117 (provide 'benchmark) | |
52401 | 118 |
93975
1e3a407766b9
Fix up comment convention on the arch-tag lines.
Stefan Monnier <monnier@iro.umontreal.ca>
parents:
79704
diff
changeset
|
119 ;; arch-tag: be570e24-4b51-4784-adf3-fa2b56c31946 |
49574 | 120 ;;; benchmark.el ends here |