-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathperf.el
26 lines (23 loc) · 918 Bytes
/
perf.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
(require 'benchmark)
(add-to-list 'load-path (expand-file-name "."))
(load "parinferlib")
;; from: http://ergoemacs.org/emacs/elisp_read_file_content.html
(defun get-string-from-file (filePath)
"Return filePath's file content."
(with-temp-buffer
(insert-file-contents filePath)
(buffer-string)))
(defun print-times (mode times)
"Print the output of benchmark-run."
(message " %s: %fs (w/ %d garbage collects in %fs)"
mode
(/ (nth 0 times) 30.0)
(/ (nth 1 times) 30.0)
(/ (nth 2 times) 30.0)))
(let* ((filename "tests/really_long_file")
(text (get-string-from-file filename))
(indent-times (benchmark-run 30 (parinferlib-indent-mode text)))
(paren-times (benchmark-run 30 (parinferlib-paren-mode text))))
(message "\nAverage time to process '%s' (across 30 runs)" filename)
(print-times "indent-mode" indent-times)
(print-times " paren-mode" paren-times))