-
Notifications
You must be signed in to change notification settings - Fork 0
/
benchmark.el
26 lines (21 loc) · 998 Bytes
/
benchmark.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
;; Benchmarking copied from Steve Purcell: https://github.com/purcell/emacs.d
;;
;; Stores the load times into the mk/required-times variable.
(defun mk/time-subtract-millis (b a)
(* 1000.0 (float-time (time-subtract b a))))
(defvar mk/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 `mk/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 'mk/require-times
(cons feature
(mk/time-subtract-millis (current-time)
require-start-time))
t)))))