X-Git-Url: https://code.delx.au/gnu-emacs-elpa/blobdiff_plain/a14be3c9d322fb352afce6426fdc2faef7d3fde8..90473ac8cf0c833bfec413fc18d5866208d2e3e9:/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..2de5646aa 100644 --- a/packages/context-coloring/benchmark/context-coloring-benchmark.el +++ b/packages/context-coloring/benchmark/context-coloring-benchmark.el @@ -17,8 +17,21 @@ ;; You should have received a copy of the GNU General Public License ;; along with this program. If not, see . +;;; Commentary: + +;; Benchmarks for context-coloring. + +;; `ert' instruments and benchmarks the package's functions, and the results are +;; logged to `benchmark/logs'. + +;; To run, execute `make bench' from the project root. + ;;; 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 +41,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 +62,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 +73,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 +107,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 +136,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))