mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-06 22:41:06 -08:00
* lisp/emacs-lisp/benchmark.el (benchmark-run): Allow variable.
(benchmark-run): Allow `repetitions` to be a variable rather than a constant.
This commit is contained in:
parent
66b7718901
commit
c7d2a0dd76
1 changed files with 3 additions and 3 deletions
|
|
@ -50,7 +50,7 @@ Return a list of the total elapsed time for execution, the number of
|
||||||
garbage collections that ran, and the time taken by garbage collection.
|
garbage collections that ran, and the time taken by garbage collection.
|
||||||
See also `benchmark-run-compiled'."
|
See also `benchmark-run-compiled'."
|
||||||
(declare (indent 1) (debug t))
|
(declare (indent 1) (debug t))
|
||||||
(unless (natnump repetitions)
|
(unless (or (natnump repetitions) (symbolp repetitions))
|
||||||
(setq forms (cons repetitions forms)
|
(setq forms (cons repetitions forms)
|
||||||
repetitions 1))
|
repetitions 1))
|
||||||
(let ((i (make-symbol "i"))
|
(let ((i (make-symbol "i"))
|
||||||
|
|
@ -58,7 +58,7 @@ See also `benchmark-run-compiled'."
|
||||||
(gc (make-symbol "gc")))
|
(gc (make-symbol "gc")))
|
||||||
`(let ((,gc gc-elapsed)
|
`(let ((,gc gc-elapsed)
|
||||||
(,gcs gcs-done))
|
(,gcs gcs-done))
|
||||||
(list ,(if (> repetitions 1)
|
(list ,(if (or (symbolp repetitions) (> repetitions 1))
|
||||||
;; Take account of the loop overhead.
|
;; Take account of the loop overhead.
|
||||||
`(- (benchmark-elapse (dotimes (,i ,repetitions)
|
`(- (benchmark-elapse (dotimes (,i ,repetitions)
|
||||||
,@forms))
|
,@forms))
|
||||||
|
|
@ -101,7 +101,7 @@ the command prompts for the form to benchmark.
|
||||||
For non-interactive use see also `benchmark-run' and
|
For non-interactive use see also `benchmark-run' and
|
||||||
`benchmark-run-compiled'."
|
`benchmark-run-compiled'."
|
||||||
(interactive "p\nxForm: ")
|
(interactive "p\nxForm: ")
|
||||||
(let ((result (eval `(benchmark-run ,repetitions ,form))))
|
(let ((result (eval `(benchmark-run ,repetitions ,form) t)))
|
||||||
(if (zerop (nth 1 result))
|
(if (zerop (nth 1 result))
|
||||||
(message "Elapsed time: %fs" (car result))
|
(message "Elapsed time: %fs" (car result))
|
||||||
(message "Elapsed time: %fs (%fs in %d GCs)" (car result)
|
(message "Elapsed time: %fs (%fs in %d GCs)" (car result)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue