1 (defconst context-coloring-benchmark-path
2 (file-name-directory (or load-file-name buffer-file-name)))
4 (defun context-coloring-benchmark-resolve-path (path)
5 (expand-file-name path context-coloring-benchmark-path))
7 (defun context-coloring-benchmark-log-results (result-file fixture)
9 (let ((results-buffer (current-buffer)))
11 (insert (concat fixture "\n"))
12 (prepend-to-buffer results-buffer (point-min) (point-max)))
15 (append-to-buffer results-buffer (point-min) (point-max))))
16 (append-to-file nil nil result-file))
18 (defun context-coloring-benchmark-js-mode-setup ()
19 (add-hook 'js-mode-hook 'context-coloring-mode)
20 (elp-instrument-package "context-coloring-"))
22 (defun context-coloring-benchmark-js-mode-teardown ()
23 (remove-hook 'js-mode-hook 'context-coloring-mode))
25 (defun context-coloring-benchmark-js-mode-run ()
26 (context-coloring-benchmark-js-mode-setup)
27 (let ((result-file (context-coloring-benchmark-resolve-path
28 (concat "./results-js-mode-" (format-time-string "%s") ".log"))))
29 (dolist (path '("./fixtures/jquery-2.1.1.js"
30 "./fixtures/lodash-2.4.1.js"
31 "./fixtures/async-0.9.0.js"
32 "./fixtures/mkdirp-0.5.0.js"))
33 (let ((fixture (context-coloring-benchmark-resolve-path path)))
40 (context-coloring-benchmark-log-results result-file fixture))))
41 (context-coloring-benchmark-js-mode-teardown))
43 (defun context-coloring-benchmark-js2-mode-setup ()
44 (add-to-list 'load-path (context-coloring-benchmark-resolve-path
47 (setq js2-mode-show-parse-errors nil)
48 (setq js2-mode-show-strict-warnings nil)
49 (add-to-list 'auto-mode-alist '("\\.js\\'" . js2-mode))
50 (add-hook 'js2-mode-hook 'context-coloring-mode)
51 (elp-instrument-package "context-coloring-"))
53 (defun context-coloring-benchmark-js2-mode-teardown ()
54 (remove-hook 'js2-mode-hook 'context-coloring-mode)
55 (setq auto-mode-alist (delete '("\\.js\\'" . js2-mode)
57 (setq js2-mode-show-strict-warnings t)
58 (setq js2-mode-show-parse-errors t)
59 (setq load-path (delete (context-coloring-benchmark-resolve-path
60 "../test/fixtures/js2-mode")
63 (defun context-coloring-benchmark-js2-mode-run ()
64 (context-coloring-benchmark-js2-mode-setup)
65 (let ((result-file (context-coloring-benchmark-resolve-path
66 (concat "./results-js2-mode-" (format-time-string "%s") ".log"))))
67 (dolist (path '("./fixtures/jquery-2.1.1.js"
68 "./fixtures/lodash-2.4.1.js"
69 "./fixtures/async-0.9.0.js"
70 "./fixtures/mkdirp-0.5.0.js"))
71 (let ((fixture (context-coloring-benchmark-resolve-path path)))
76 (context-coloring-benchmark-log-results result-file fixture))))
77 (context-coloring-benchmark-js2-mode-teardown))
79 (defun context-coloring-benchmark-run ()
80 ;; (context-coloring-benchmark-js-mode-run)
81 (context-coloring-benchmark-js2-mode-run)