By Xah Lee. Date: .
(require 'benchmark)
(defun xf1 (Xfname Mode)
"create temp buffer, insert file Xfname, make it major mode Mode"
(let ((xbuf (generate-new-buffer "xtestspeed" t)))
(set-buffer xbuf)
(insert-file-contents Xfname nil nil nil t)
(funcall (intern-soft Mode))
))
(setq xi 1)
(setq xfile "~/web/xx1.html")
(benchmark-run xi (xf1 xfile 'xah-html-mode ))
(benchmark-run xi (xf1 xfile 'html-mode ))
(benchmark-run xi (xf1 xfile 'mhtml-mode ))
(setq xi 100)
(defun xf3 (Xfname Mode)
"create temp buffer, insert file Xfname, make it major mode Mode"
(let ()
(find-file-literally Xfname)
(funcall (intern-soft Mode))
(kill-buffer)))
(benchmark-run xi (xf3 "~/web/xx1.html" 'xah-html-mode ))
(benchmark-run xi (xf3 "~/web/xx1.html" 'html-mode ))
(benchmark-run xi (xf3 "~/web/xx1.html" 'mhtml-mode ))
(setq xfiles (directory-files "c:/Users/xah/web/xahlee_info/talk_show/" t "html$" t))
(setq xi 1)
(defun xf2 (Mode)
"create temp buffer, insert file Xfname, make it major mode Mode"
(let ()
(mapc
(lambda (x)
(find-file-literally x)
(funcall (intern-soft Mode))
(kill-buffer))
xfiles)))
(benchmark-run xi (xf2 'xah-html-mode ))
(benchmark-run xi (xf2 'html-mode ))
(benchmark-run xi (xf2 'mhtml-mode ))