Skip to content

Instantly share code, notes, and snippets.

@mgalgs
Created August 5, 2013 18:45
Show Gist options
  • Save mgalgs/6158338 to your computer and use it in GitHub Desktop.
Save mgalgs/6158338 to your computer and use it in GitHub Desktop.
diff --git a/magit.el b/magit.el
index 4b3c1fa..4d5a108 100644
--- a/magit.el
+++ b/magit.el
@@ -1075,13 +1075,29 @@ Read `completing-read' documentation for the meaning of the argument."
(defun magit-cmd-insert (cmd args)
(insert (magit-cmd-output cmd args)))
+(defun magit-perf-log (msg)
+ "Log a msg to the magit perf log"
+ (flet ((message (&rest args) (ignore)))
+ (with-temp-buffer
+ (insert msg)
+ (append-to-file (point-min)
+ (point-max)
+ "/tmp/magit-perf-log.txt"))))
+
(defun magit-cmd-output (cmd args)
- (with-output-to-string
- (with-current-buffer standard-output
- (apply #'process-file
- cmd
- nil (list t nil) nil
- args))))
+ (let ((time-before (float-time)))
+ (magit-perf-log (format "Running %s %s\n" cmd args))
+ (with-output-to-string
+ (with-current-buffer standard-output
+ (apply #'process-file
+ cmd
+ nil (list t nil) nil
+ args)))
+ (magit-perf-log (format "%s %s --> Elapsed: %f seconds\n"
+ cmd
+ args
+ (- (float-time)
+ time-before)))))
(defun magit-git-string (&rest args)
(magit-trim-line (magit-git-output args)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment