X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/dd975f04da80c99b07419a6a33541bece0bbd69a..fd99dfe4bc82545d113f109cc87450918db56fba:/packages/context-coloring/benchmark/context-coloring-benchmark.el diff --git a/packages/context-coloring/benchmark/context-coloring-benchmark.el b/packages/context-coloring/benchmark/context-coloring-benchmark.el index 004b66fbe..e020f6fae 100644 --- a/packages/context-coloring/benchmark/context-coloring-benchmark.el +++ b/packages/context-coloring/benchmark/context-coloring-benchmark.el @@ -1,4 +1,4 @@ -;;; 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. @@ -17,8 +17,18 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . +;;; 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.") @@ -28,7 +38,7 @@ (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 @@ -49,7 +59,8 @@ asynchrony." "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 @@ -59,8 +70,9 @@ exhausted, call STOP instead." (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" @@ -92,7 +104,7 @@ all are done." (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" @@ -121,7 +133,6 @@ all are done." (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))