branch: elpa/parseclj
commit 6fe4ce6095321f59e936f4d221f85b464bfaf433
Author: Arne Brasseur <[email protected]>
Commit: Arne Brasseur <[email protected]>
Add script to compare speed of edn.el and clj-parse.el
---
clj-lex.el | 4 ++--
clj-parse.el | 10 ++++++----
tests/speed-comparison.el | 21 +++++++++++++++++++++
3 files changed, 29 insertions(+), 6 deletions(-)
diff --git a/clj-lex.el b/clj-lex.el
index e0bdb6d21f..3e81c34223 100644
--- a/clj-lex.el
+++ b/clj-lex.el
@@ -155,7 +155,6 @@ behavior."
(let ((pos (point)))
(right-char)
(while (not (or (equal (char-after (point)) ?\") (clj-lex-at-eof?)))
- (message (buffer-substring-no-properties pos (point)))
(if (equal (char-after (point)) ?\\)
(right-char 2)
(right-char)))
@@ -292,7 +291,8 @@ behavior."
(right-char))
(clj-lex-token :lex-error (buffer-substring-no-properties pos
(point)) pos 'error-type :invalid-hashtag-dispatcher)))))
- ":("))))
+ (t
+ (concat ":(" (char-to-string char)))))))
(provide 'clj-lex)
diff --git a/clj-parse.el b/clj-parse.el
index 163c7441e6..e55a8ba379 100644
--- a/clj-parse.el
+++ b/clj-parse.el
@@ -130,14 +130,16 @@
(let ((node (pop stack)))
(funcall reduceN stack node coll))
;; Syntax error
- (error "Syntax Error"))))
+ (progn
+ (message "STACK: %S , CLOSER: %S" stack closer-token)
+ (error "Syntax Error")))))
(defun clj-parse-reduce (reduce-leaf reduce-node)
(let ((stack nil))
(while (not (eq (clj-lex-token-type (setq token (clj-lex-next))) :eof))
- (message "STACK: %S" stack)
- (message "TOKEN: %S\n" token)
+ ;; (message "STACK: %S" stack)
+ ;; (message "TOKEN: %S\n" token)
;; Reduce based on the top item on the stack (collections)
(let ((token-type (clj-lex-token-type token)))
@@ -154,7 +156,7 @@
;; reduce root
(setf stack (funcall reduce-node stack '((type . :root) (pos . 0)) stack))
- (message "RESULT: %S" stack)
+ ;; (message "RESULT: %S" stack)
stack))
diff --git a/tests/speed-comparison.el b/tests/speed-comparison.el
new file mode 100644
index 0000000000..8f315be5d3
--- /dev/null
+++ b/tests/speed-comparison.el
@@ -0,0 +1,21 @@
+(with-current-buffer (find-file-noselect "/home/arne/tmp/edn2.list")
+ (goto-char 1)
+ (while (and (< (point) (point-max)))
+ (end-of-line)
+ (let* ((fn (buffer-substring-no-properties (line-beginning-position)
(point)))
+ (buff (find-file-noselect fn))
+ (edn-time 0)
+ (clj-time 0))
+ ;;(message fn)
+ (with-current-buffer buff
+ (let ((start (time-to-seconds (current-time))))
+ (clj-parse-edn)
+ (setq clj-time (+ clj-time (- (time-to-seconds (current-time))
start))))
+ (goto-char 1)
+ (let ((start (time-to-seconds (current-time))))
+ (edn-read)
+ (setq edn-time (+ edn-time (- (time-to-seconds (current-time))
start)))))
+ (kill-buffer buff)
+ (when (< (point) (point-max)) (right-char))
+ (with-current-buffer "*edn-parse-time-results*"
+ (insert "{:file \"" fn "\", :edn-time " (number-to-string edn-time) ",
:clj-time " (number-to-string clj-time) "}\n")))))