forked from purcell/emacs.d
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init-benchmarking.el
25 lines (19 loc) · 920 Bytes
/
init-benchmarking.el
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
(defun sanityinc/time-subtract-millis (b a)
(* 1000.0 (float-time (time-subtract b a))))
(defvar sanityinc/require-times nil
"A list of (FEATURE . LOAD-DURATION).
LOAD-DURATION is the time taken in milliseconds to load FEATURE.")
(defadvice require
(around build-require-times (feature &optional filename noerror) activate)
"Note in `sanityinc/require-times' the time taken to require each feature."
(let* ((already-loaded (memq feature features))
(require-start-time (and (not already-loaded) (current-time))))
(prog1
ad-do-it
(when (and (not already-loaded) (memq feature features))
(add-to-list 'sanityinc/require-times
(cons feature
(sanityinc/time-subtract-millis (current-time)
require-start-time))
t)))))
(provide 'init-benchmarking)