Use lexical binding in benchmark.el

* lisp/emacs-lisp/benchmark.el: Enable lexical binding.
(benchmark-elapse): Use 'declare'.
* test/lisp/emacs-lisp/benchmark-tests.el: Add test suite.
This commit is contained in:
Tino Calancha 2017-03-03 18:26:30 +09:00
parent f5388ba8a7
commit 244de7b0ed
2 changed files with 53 additions and 4 deletions

View file

@ -1,4 +1,4 @@
;;; benchmark.el --- support for benchmarking code
;;; benchmark.el --- support for benchmarking code -*- lexical-binding: t -*-
;; Copyright (C) 2003-2017 Free Software Foundation, Inc.
@ -33,6 +33,7 @@
(defmacro benchmark-elapse (&rest forms)
"Return the time in seconds elapsed for execution of FORMS."
(declare (indent 0) (debug t))
(let ((t1 (make-symbol "t1"))
(t2 (make-symbol "t2")))
`(let (,t1 ,t2)
@ -41,9 +42,6 @@
(setq ,t2 (current-time))
(float-time (time-subtract ,t2 ,t1)))))
(put 'benchmark-elapse 'edebug-form-spec t)
(put 'benchmark-elapse 'lisp-indent-function 0)
;;;###autoload
(defmacro benchmark-run (&optional repetitions &rest forms)
"Time execution of FORMS.