branch: master commit f3e4d7bf360f05f75ddfb2e36a46c1b306300f35 Author: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com> Commit: Jackson Ray Hamilton <jack...@jacksonrayhamilton.com>
Improve benchmarks. --- Makefile | 3 +- README.md | 10 +++--- benchmark/context-coloring-benchmark.el | 47 +++++++++++++++++++++++++++++++ benchmark/scenarios.el | 19 ------------ test/context-coloring-test.el | 4 +- 5 files changed, 56 insertions(+), 27 deletions(-) diff --git a/Makefile b/Makefile index 07313bb..656a035 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,8 @@ benchjs: benchel: emacs -Q -L . \ -l context-coloring \ - -l benchmark/scenarios.el + -l benchmark/context-coloring-benchmark \ + -f context-coloring-benchmark-run compile: emacs -Q -batch -f batch-byte-compile *.el diff --git a/README.md b/README.md index deccbb8..f58c10b 100644 --- a/README.md +++ b/README.md @@ -29,11 +29,11 @@ can also be integrated into your workflow via [flycheck][]. ## Features - Light and dark color schemes. -- Really fast async AST parsing. Some parse / recolor times: - - jQuery (9191 lines): 0.41 seconds - - lodash (6786 lines): 0.22 seconds - - Async (1124 lines): 28 milliseconds - - mkdirp (98 lines): instant +- Fast async AST parsing. Some total parse + recolor times: + - jQuery (9191 lines): 0.72 seconds + - Lodash (6786 lines): 0.40 seconds + - Async (1124 lines): 0.20 seconds + - mkdirp (98 lines): 0.09 seconds ## Usage diff --git a/benchmark/context-coloring-benchmark.el b/benchmark/context-coloring-benchmark.el new file mode 100644 index 0000000..5476847 --- /dev/null +++ b/benchmark/context-coloring-benchmark.el @@ -0,0 +1,47 @@ +(defconst context-coloring-benchmark-path + (file-name-directory (or load-file-name buffer-file-name))) + +(defun context-coloring-benchmark-resolve-path (path) + (expand-file-name path context-coloring-benchmark-path)) + +(defun context-coloring-benchmark-setup () + (setq context-coloring-benchmark-colorization t) + (add-hook 'js-mode-hook 'context-coloring-mode) + (elp-instrument-package "context-coloring-")) + +(defun context-coloring-benchmark-teardown () + (setq context-coloring-benchmark-colorization nil) + (remove-hook 'js-mode-hook 'context-coloring-mode)) + +(defun context-coloring-benchmark-run () + (context-coloring-benchmark-setup) + (let ((result-file (context-coloring-benchmark-resolve-path (concat "./results.log")))) + + (dolist (path '("./fixtures/jquery-2.1.1.js" + "./fixtures/lodash-2.4.1.js" + "./fixtures/async-0.9.0.js" + "./fixtures/mkdirp-0.5.0.js")) + + (let ((fixture (context-coloring-benchmark-resolve-path path))) + + ;; Test 5 times. + (find-file fixture) + (dotimes (n 4) + (sit-for 1) + (revert-buffer t t)) + (sit-for 1) + + (elp-results) + (let ((results-buffer (current-buffer))) + (with-temp-buffer + (insert (concat fixture "\n")) + (prepend-to-buffer results-buffer (point-min) (point-max))) + (with-temp-buffer + (insert "\n") + (append-to-buffer results-buffer (point-min) (point-max)))) + + (append-to-file nil nil result-file))) + + (find-file result-file)) + + (context-coloring-benchmark-teardown)) diff --git a/benchmark/scenarios.el b/benchmark/scenarios.el deleted file mode 100644 index 7eed6ec..0000000 --- a/benchmark/scenarios.el +++ /dev/null @@ -1,19 +0,0 @@ -;; Setup -(add-hook 'js-mode-hook 'context-coloring-mode) -(elp-instrument-package "context-coloring-") - -(dolist (path '("./fixtures/jquery-2.1.1.js" - "./fixtures/lodash-2.4.1.js" - "./fixtures/async-0.9.0.js" - "./fixtures/mkdirp-0.5.0.js")) - - ;; Test 5 times. - (find-file (expand-file-name - path - (file-name-directory (or load-file-name buffer-file-name)))) - (dotimes (n 4) - (sit-for 2) - (revert-buffer t t)) - (sit-for 2)) - -(elp-results) diff --git a/test/context-coloring-test.el b/test/context-coloring-test.el index a8588fb..b942558 100644 --- a/test/context-coloring-test.el +++ b/test/context-coloring-test.el @@ -1,8 +1,8 @@ -(defconst context-coloring-path +(defconst context-coloring-test-path (file-name-directory (or load-file-name buffer-file-name))) (defun context-coloring-test-resolve-path (path) - (expand-file-name path context-coloring-path)) + (expand-file-name path context-coloring-test-path)) ;; Load expected output constants. (load-file (context-coloring-test-resolve-path "./fixtures/scopes.el"))