core: display time spent in user-config in home buffer
This commit is contained in:
parent
d3c594512d
commit
f1f8db002a
|
@ -2446,18 +2446,21 @@ depends on it."
|
|||
(let ((stats (configuration-layer/configured-packages-stats
|
||||
configuration-layer--used-packages)))
|
||||
(spacemacs-buffer/insert-page-break)
|
||||
(spacemacs-buffer/append
|
||||
(format "\n%s packages loaded in %.3fs (e:%s r:%s l:%s b:%s)"
|
||||
(cadr (assq 'total stats))
|
||||
configuration-layer--spacemacs-startup-time
|
||||
(cadr (assq 'elpa stats))
|
||||
(cadr (assq 'recipe stats))
|
||||
(cadr (assq 'local stats))
|
||||
(cadr (assq 'built-in stats))))
|
||||
(with-current-buffer (get-buffer-create spacemacs-buffer-name)
|
||||
(let ((buffer-read-only nil))
|
||||
(spacemacs-buffer//center-line)
|
||||
(insert "\n")))))
|
||||
(spacemacs-buffer/append
|
||||
(format "\n%s packages loaded in %.3fs (e:%s r:%s l:%s b:%s)"
|
||||
(cadr (assq 'total stats))
|
||||
configuration-layer--spacemacs-startup-time
|
||||
(cadr (assq 'elpa stats))
|
||||
(cadr (assq 'recipe stats))
|
||||
(cadr (assq 'local stats))
|
||||
(cadr (assq 'built-in stats))))
|
||||
(spacemacs-buffer//center-line)
|
||||
(spacemacs-buffer/append (format "\n(%.3fs spent in your user-config)"
|
||||
dotspacemacs--user-config-elapsed-time))
|
||||
(spacemacs-buffer//center-line)
|
||||
(insert "\n")))))
|
||||
|
||||
(defun configuration-layer//get-indexed-elpa-package-names ()
|
||||
"Return a list of all ELPA packages in indexed packages and dependencies."
|
||||
|
|
|
@ -15,6 +15,11 @@
|
|||
(defconst dotspacemacs-test-results-buffer "*dotfile-test-results*"
|
||||
"Name of the buffer to display dotfile test results.")
|
||||
|
||||
(defvar dotspacemacs--user-config-elapsed-time 0
|
||||
"Time spent in `dotspacemacs/user-config' function.
|
||||
Useful for users in order to given them a hint of potential bottleneck in
|
||||
their configuration.")
|
||||
|
||||
(let* ((env (getenv "SPACEMACSDIR"))
|
||||
(env-dir (when env (expand-file-name (concat env "/"))))
|
||||
(env-init (and env-dir (expand-file-name "init.el" env-dir)))
|
||||
|
@ -500,6 +505,14 @@ Returns non nil if the layer has been effectively inserted."
|
|||
(load-file (dotspacemacs/location))
|
||||
t))
|
||||
|
||||
(defun dotspacemacs//profile-user-config (f &rest args)
|
||||
"Compute time taken by the `dotspacemacs/user-config' function.
|
||||
Set the variable"
|
||||
(let ((stime (current-time)))
|
||||
(apply f args)
|
||||
(setq dotspacemacs--user-config-elapsed-time
|
||||
(float-time (time-subtract (current-time) stime)))))
|
||||
|
||||
(defun dotspacemacs/sync-configuration-layers (&optional arg)
|
||||
"Synchronize declared layers in dotfile with spacemacs.
|
||||
|
||||
|
@ -644,7 +657,8 @@ If ARG is non nil then Ask questions to the user before installing the dotfile."
|
|||
(if (file-exists-p dotspacemacs)
|
||||
(unless (with-demoted-errors "Error loading .spacemacs: %S"
|
||||
(load dotspacemacs))
|
||||
(dotspacemacs/safe-load)))))
|
||||
(dotspacemacs/safe-load))))
|
||||
(advice-add 'dotspacemacs/user-config :around 'dotspacemacs//profile-user-config))
|
||||
|
||||
(defun spacemacs/title-prepare (title-format)
|
||||
"A string is printed verbatim except for %-constructs.
|
||||
|
|
Loading…
Reference in a new issue