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
## 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
--- /dev/null
+(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))
+++ /dev/null
-;; 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)
-(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"))