Skip to content

Commit

Permalink
optionally benchmark how long refreshes take
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed Apr 29, 2015
1 parent 35cd6c7 commit babd1f8
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion magit-mode.el
Original file line number Diff line number Diff line change
Expand Up @@ -468,13 +468,16 @@ tracked in the current repository."
(defvar magit-refresh-buffer-hook nil
"Hook run after refreshing a file-visiting buffer.")

(defvar magit-refresh-verbose nil)
(defvar-local magit-refresh-start-time nil)

(defun magit-refresh-buffer ()
"Refresh the current Magit buffer.
Uses the buffer-local `magit-refresh-function'."
(setq magit-refresh-start-time (current-time))
(when magit-refresh-function
(when magit-refresh-verbose
(message "Refreshing %s..." (current-buffer)))
(let* ((buffer (current-buffer))
(windows
(--mapcat (with-selected-window it
Expand Down Expand Up @@ -503,7 +506,11 @@ Uses the buffer-local `magit-refresh-function'."
(apply #'magit-section-goto-successor (cdr window)))))
(run-hooks 'magit-refresh-buffer-hook)
(magit-section-update-highlight)
(set-buffer-modified-p nil))))
(set-buffer-modified-p nil))
(when magit-refresh-verbose
(message "Refreshing %s...done (%.3fs)" (current-buffer)
(float-time (time-subtract (current-time)
magit-refresh-start-time))))))

(defun magit-revert-buffers (&optional force)
"Revert unmodified file-visiting buffers of the current repository.
Expand Down

0 comments on commit babd1f8

Please sign in to comment.