emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Emacs-diffs] master c7d2a0d: * lisp/emacs-lisp/benchmark.el (benchmark-


From: Stefan Monnier
Subject: [Emacs-diffs] master c7d2a0d: * lisp/emacs-lisp/benchmark.el (benchmark-run): Allow variable.
Date: Mon, 26 Mar 2018 21:07:41 -0400 (EDT)

branch: master
commit c7d2a0dd76fbfaedb4caedac261bd0a8944281a8
Author: Stefan Monnier <address@hidden>
Commit: Stefan Monnier <address@hidden>

    * lisp/emacs-lisp/benchmark.el (benchmark-run): Allow variable.
    
    (benchmark-run): Allow `repetitions` to be a variable rather than a 
constant.
---
 lisp/emacs-lisp/benchmark.el | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/lisp/emacs-lisp/benchmark.el b/lisp/emacs-lisp/benchmark.el
index b86b56b..2f4e38f 100644
--- a/lisp/emacs-lisp/benchmark.el
+++ b/lisp/emacs-lisp/benchmark.el
@@ -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.
 See also `benchmark-run-compiled'."
   (declare (indent 1) (debug t))
-  (unless (natnump repetitions)
+  (unless (or (natnump repetitions) (symbolp repetitions))
     (setq forms (cons repetitions forms)
          repetitions 1))
   (let ((i (make-symbol "i"))
@@ -58,7 +58,7 @@ See also `benchmark-run-compiled'."
        (gc (make-symbol "gc")))
     `(let ((,gc gc-elapsed)
           (,gcs gcs-done))
-       (list ,(if (> repetitions 1)
+       (list ,(if (or (symbolp repetitions) (> repetitions 1))
                  ;; Take account of the loop overhead.
                  `(- (benchmark-elapse (dotimes (,i ,repetitions)
                                          ,@forms))
@@ -101,7 +101,7 @@ the command prompts for the form to benchmark.
 For non-interactive use see also `benchmark-run' and
 `benchmark-run-compiled'."
   (interactive "p\nxForm: ")
-  (let ((result (eval `(benchmark-run ,repetitions ,form))))
+  (let ((result (eval `(benchmark-run ,repetitions ,form) t)))
     (if (zerop (nth 1 result))
        (message "Elapsed time: %fs" (car result))
       (message "Elapsed time: %fs (%fs in %d GCs)" (car result)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]