Last active
December 15, 2015 21:19
-
-
Save sluchin/5324661 to your computer and use it in GitHub Desktop.
require 時間計測
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;; require 時間を計測する | |
(defvar benchmark-alist nil) | |
(defadvice require | |
(around require-benchmark | |
(feature &optional filename noerror) | |
activate compile) | |
(let* ((before (time-to-seconds (current-time))) | |
(result ad-do-it) | |
(after (time-to-seconds (current-time))) | |
(time (* (- after before) 1000))) | |
(unless (assq result benchmark-alist) | |
(add-to-list 'benchmark-alist (cons result time))))) | |
;; 表示 | |
(defun print-benchmark () | |
"Print benchmark." | |
(interactive) | |
(let ((all 0)) | |
(dolist (alist (reverse benchmark-alist)) | |
(setq all (+ all (cdr alist))) | |
(message "%-18s %.6f msec" (car alist) (cdr alist))) | |
(message "%-18s %.6f msec" "all" all))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment