Skip to content

Instantly share code, notes, and snippets.

@sluchin
Last active December 15, 2015 21:19
Show Gist options
  • Save sluchin/5324661 to your computer and use it in GitHub Desktop.
Save sluchin/5324661 to your computer and use it in GitHub Desktop.
require 時間計測
;;; 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