mirror of https://github.com/djcb/mu.git
mu4e: improve search/rendering benchmark
Include numbers for search from start to finish.
This commit is contained in:
parent
d7b0e64859
commit
cc32257f1c
|
@ -297,8 +297,7 @@ followed by the docid, followed by `mu4e~headers-docid-post'.")
|
||||||
In the format needed for `mu4e-read-option'.")
|
In the format needed for `mu4e-read-option'.")
|
||||||
|
|
||||||
|
|
||||||
;;; Clear
|
(defvar mu4e~headers-search-start nil)
|
||||||
|
|
||||||
(defvar mu4e~headers-render-start nil)
|
(defvar mu4e~headers-render-start nil)
|
||||||
(defvar mu4e~headers-render-time nil)
|
(defvar mu4e~headers-render-time nil)
|
||||||
|
|
||||||
|
@ -311,6 +310,9 @@ This is mostly useful for profiling.")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
;;; Clear
|
||||||
|
|
||||||
(defun mu4e~headers-clear (&optional msg)
|
(defun mu4e~headers-clear (&optional msg)
|
||||||
"Clear the header buffer and related data structures."
|
"Clear the header buffer and related data structures."
|
||||||
(when (buffer-live-p (mu4e-get-headers-buffer))
|
(when (buffer-live-p (mu4e-get-headers-buffer))
|
||||||
|
@ -323,11 +325,6 @@ This is mostly useful for profiling.")
|
||||||
(goto-char (point-min))
|
(goto-char (point-min))
|
||||||
(insert (propertize msg 'face 'mu4e-system-face 'intangible t)))))))
|
(insert (propertize msg 'face 'mu4e-system-face 'intangible t)))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;;; Misc
|
;;; Misc
|
||||||
|
|
||||||
|
@ -821,6 +818,7 @@ true, do *not* update the query history stack."
|
||||||
(switch-to-buffer buf))
|
(switch-to-buffer buf))
|
||||||
(run-hook-with-args 'mu4e-search-hook expr)
|
(run-hook-with-args 'mu4e-search-hook expr)
|
||||||
(mu4e~headers-clear mu4e~search-message)
|
(mu4e~headers-clear mu4e~search-message)
|
||||||
|
(setq mu4e~headers-search-start (float-time))
|
||||||
(mu4e--server-find
|
(mu4e--server-find
|
||||||
rewritten-expr
|
rewritten-expr
|
||||||
mu4e-search-threads
|
mu4e-search-threads
|
||||||
|
@ -830,27 +828,34 @@ true, do *not* update the query history stack."
|
||||||
mu4e-headers-skip-duplicates
|
mu4e-headers-skip-duplicates
|
||||||
mu4e-headers-include-related)))
|
mu4e-headers-include-related)))
|
||||||
|
|
||||||
|
(defun mu4e~headers-benchmark-message (count)
|
||||||
|
"Get some report message for messaging search and rendering speed."
|
||||||
|
(if (and mu4e-headers-report-render-time
|
||||||
|
mu4e~headers-search-start
|
||||||
|
mu4e~headers-render-start
|
||||||
|
(> count 0))
|
||||||
|
(let ((render-time-ms (* 1000(- (float-time) mu4e~headers-render-start)))
|
||||||
|
(search-time-ms (* 1000(- (float-time) mu4e~headers-search-start))))
|
||||||
|
(format (concat
|
||||||
|
"; search: %0.1f ms (%0.2f ms/msg)"
|
||||||
|
"; render: %0.1f ms (%0.2f ms/msg)")
|
||||||
|
search-time-ms (/ search-time-ms count)
|
||||||
|
render-time-ms (/ render-time-ms count)))
|
||||||
|
""))
|
||||||
|
|
||||||
(defun mu4e~headers-found-handler (count)
|
(defun mu4e~headers-found-handler (count)
|
||||||
"Create a one line description of the number of headers found
|
"Create a one line description of the number of headers found
|
||||||
after the end of the search results."
|
after the end of the search results."
|
||||||
(when mu4e~headers-render-start ;; for benchmarking.
|
|
||||||
(setq mu4e~headers-render-time
|
|
||||||
(- (float-time) mu4e~headers-render-start)
|
|
||||||
mu4e~headers-render-start nil))
|
|
||||||
(when (buffer-live-p (mu4e-get-headers-buffer))
|
(when (buffer-live-p (mu4e-get-headers-buffer))
|
||||||
(with-current-buffer (mu4e-get-headers-buffer)
|
(with-current-buffer (mu4e-get-headers-buffer)
|
||||||
(save-excursion
|
(save-excursion
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(let ((inhibit-read-only t)
|
(let ((inhibit-read-only t)
|
||||||
(str (if (zerop count) mu4e~no-matches mu4e~end-of-results))
|
(str (if (zerop count) mu4e~no-matches mu4e~end-of-results))
|
||||||
(msg (format "Found %d matching message%s"
|
(msg (format "Found %d matching message%s%s"
|
||||||
count (if (= 1 count) "" "s")))
|
count (if (= 1 count) "" "s")
|
||||||
(render-time-ms (when mu4e~headers-render-time
|
(mu4e~headers-benchmark-message count))))
|
||||||
(* mu4e~headers-render-time 1000))))
|
|
||||||
;; benchmarking.
|
|
||||||
(when (and mu4e-headers-report-render-time (> count 0))
|
|
||||||
(setq msg (concat msg (format " (rendering took %0.1f ms, %0.2f ms/msg)"
|
|
||||||
render-time-ms (/ render-time-ms count)))))
|
|
||||||
(insert (propertize str 'face 'mu4e-system-face 'intangible t))
|
(insert (propertize str 'face 'mu4e-system-face 'intangible t))
|
||||||
(unless (zerop count)
|
(unless (zerop count)
|
||||||
(mu4e-message "%s" msg))))
|
(mu4e-message "%s" msg))))
|
||||||
|
|
Loading…
Reference in New Issue