-;;; benchmark/context-coloring-benchmark.el --- Benchmarks for context coloring. -*- lexical-binding: t; -*-
+;;; context-coloring-benchmark.el --- Benchmarks for context coloring -*- lexical-binding: t; -*-
;; Copyright (C) 2014-2015 Free Software Foundation, Inc.
;; You should have received a copy of the GNU General Public License
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
+;;; Commentary:
+
+;; Benchmarks for context coloring.
+
+;; Use with `make bench'.
+
;;; Code:
+(require 'context-coloring)
+(require 'js2-mode)
+
+
(defconst context-coloring-benchmark-path
(file-name-directory (or load-file-name buffer-file-name))
"This file's directory.")
(expand-file-name path context-coloring-benchmark-path))
(defun context-coloring-benchmark-log-results (result-file fixture)
- "Log benchmarking results for FIXTURE to RESULT-FILE."
+ "Log benchmarking results to RESULT-FILE for fixture FIXTURE."
(elp-results)
(let ((results-buffer (current-buffer)))
(with-temp-buffer
"Run the next test in LIST by calling CONTINUE. When LIST is
exhausted, call STOP instead."
(if (null list)
- (context-coloring-benchmark-next-tick stop)
+ (progn
+ (context-coloring-benchmark-next-tick stop))
(context-coloring-benchmark-next-tick
(lambda ()
(funcall
(context-coloring-benchmark-next (cdr list) continue stop)))))))
(defun context-coloring-benchmark-async (title setup teardown fixtures callback)
- "Measure the performance of all FIXTURES, calling CALLBACK when
-all are done."
+ "Execute a benchmark titled TITLE with SETUP and TEARDOWN
+callbacks. Measure the performance of all FIXTURES, calling
+CALLBACK when all are done."
(funcall setup)
(let ((result-file (context-coloring-benchmark-resolve-path
(format "./logs/results-%s-%s.log"
(find-file fixture)))
(lambda ()
(funcall teardown)
- (if callback (funcall callback))))))
+ (when callback (funcall callback))))))
(defconst context-coloring-benchmark-js-fixtures
'("./fixtures/jquery-2.1.1.js"
(defun context-coloring-benchmark-js2-mode-setup ()
"Preparation logic for `js2-mode'."
- (require 'js2-mode)
(setq js2-mode-show-parse-errors nil)
(setq js2-mode-show-strict-warnings nil)
(add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))