]> code.delx.au - gnu-emacs-elpa/commitdiff
Improve benchmarks.
authorJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 23 Nov 2014 20:58:38 +0000 (12:58 -0800)
committerJackson Ray Hamilton <jackson@jacksonrayhamilton.com>
Sun, 23 Nov 2014 20:58:38 +0000 (12:58 -0800)
Makefile
README.md
benchmark/context-coloring-benchmark.el [new file with mode: 0644]
benchmark/scenarios.el [deleted file]
test/context-coloring-test.el

index 07313bbe58acaf9a9f12833f104eae6cbbbc92a3..656a035d6e217db2df7d0745fdef6a2efcbe5bea 100644 (file)
--- 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
index deccbb8d7023ef1b084ba1181b89785a9981427c..f58c10b8a34c5fec2b170e54a887a2150dac77b2 100644 (file)
--- 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 (file)
index 0000000..5476847
--- /dev/null
@@ -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 (file)
index 7eed6ec..0000000
+++ /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)
index a8588fb9e8b6b9351f430e5f68d9a2ccc51cf710..b942558cb48d0d5a16ad8bba9500d1c39d562899 100644 (file)
@@ -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"))