mirror of
https://github.com/joaotavora/yasnippet.git
synced 2025-10-13 13:13:03 +00:00
enhancement: slightly better benchmarks
This commit is contained in:
parent
66aaf614f5
commit
1a9221cf0d
@ -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)))))
|
||||
|
Loading…
x
Reference in New Issue
Block a user