From 1a9221cf0d789ddaa85784e037355b16c16b9500 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20T=C3=A1vora?= Date: Mon, 2 Jul 2012 00:26:26 +0100 Subject: [PATCH] enhancement: slightly better benchmarks --- yasnippet-benchmarks.el | 49 ++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 23 deletions(-) diff --git a/yasnippet-benchmarks.el b/yasnippet-benchmarks.el index bb29873..0ef4390 100644 --- a/yasnippet-benchmarks.el +++ b/yasnippet-benchmarks.el @@ -4,6 +4,12 @@ (split-string (buffer-string)))) +(defmacro yas/time (&rest body) + (let ((start-sym (gensym))) + `(let ((,start-sym (current-time))) + ,@body + (float-time (time-subtract (current-time) ,start-sym))))) + (defun yas/run-some-benchmarks () (interactive) (let* ((dummy-mode-names (subseq manywords 0 10)) @@ -17,52 +23,49 @@ dummy-mode-names))) (yas/verbosity 1)) (with-current-buffer (get-buffer-create "*yas/benchmarks*") - (erase-buffer) + (end-of-buffer) + (insert (format "\nComparison of `yas/reload-all' performance: (%s)\n\n" (current-time-string))) ;; jit, no compiled, fastest ;; (yas/with-snippet-dirs (list dummy-snippets) ;; (yas/recompile-all) - (let ((start (current-time))) - (yas/reload-all) - (insert (format "JIT NO-COMPILED: %s s\n" (float-time (time-subtract (current-time) start)))))) + (let ((yas/auto-compile-snippets nil)) + (insert (format "JIT NO-COMPILED NO-AUTOCOMP: %s s\n" + (yas/time (yas/reload-all)))))) ;; jit, compiled, this is equivalent to the first one. The real work ;; will be done when modes are effectively accessed ;; (yas/with-snippet-dirs (list dummy-snippets) - (let ((start (current-time))) - (yas/reload-all) - (insert (format "JIT COMPILED: %s s\n" (float-time (time-subtract (current-time) start)))))) + (let ((yas/auto-compile-snippets nil)) + (insert (format "JIT COMPILED NO-AUTOCOMP: %s s (identical to the previous case, no snippets are actually loaded)\n" + (yas/time (yas/reload-all)))))) ;; no-jit no-compiled files, slow ;; (yas/with-snippet-dirs (list dummy-snippets) - (let ((start (current-time)) - (yas/auto-compile-snippets nil)) - (yas/reload-all t) - (insert (format "NO-JIT NO-COMPILED: %s s\n" (float-time (time-subtract (current-time) start)))))) + (let ((yas/auto-compile-snippets nil)) + (insert (format "NO-JIT NO-COMPILED NO-AUTOCOMP: %s s (every snippet loaded from file)\n" + (yas/time (yas/reload-all t)))))) ;; no-jit compiled files, this is what normally happens when a user ;; interactive calls `yas/reload-all' ;; (yas/with-snippet-dirs (list dummy-snippets) (yas/recompile-all) - (let ((start (current-time)) - (yas/auto-compile-snippets nil)) - (yas/reload-all t) - (insert (format "NO-JIT COMPILED: %s s (no recompilation-needed, no auto-compilation checks)\n" (float-time (time-subtract (current-time) start)))))) + (let ((yas/auto-compile-snippets nil)) + (insert (format "NO-JIT COMPILED NO-AUTOCOMP: %s s (no recompilation-needed)\n" + (yas/time (yas/reload-all t)))))) ;; no-jit compiled files, this is what normally happens when a ;; user interactive calls `yas/reload-all', but now with ;; auto-compilation `mtime' checks ;; (yas/with-snippet-dirs (list dummy-snippets) (yas/recompile-all) - (let ((start (current-time)) - (yas/auto-compile-snippets t)) - (yas/reload-all t) - (insert (format "NO-JIT COMPILED: %s s (no recompilation needed, auto-compilation checks)\n" (float-time (time-subtract (current-time) start)))))) + (let ((yas/auto-compile-snippets t)) + (insert (format "NO-JIT COMPILED AUTOCOMP: %s s (no recompilation needed, just compilation checks)\n" + (yas/time (yas/reload-all t)))))) ;; no-jit no previous compilation, the autocompilation case, slowest ;; (yas/with-snippet-dirs (list dummy-snippets) - (let ((start (current-time)) - (yas/auto-compile-snippets t)) - (yas/reload-all t) - (insert (format "NO-JIT NO-COMPILED: %s s (recompilation needed, auto-compilation kicks in all dirs)\n" (float-time (time-subtract (current-time) start)))))) + (let ((yas/auto-compile-snippets t)) + (insert (format "NO-JIT NO-COMPILED AUTOCOMP: %s s (recompilation needed, auto-compilation kicks in all dirs)\n" + (yas/time (yas/reload-all t)))))) (pop-to-buffer (current-buffer)))))