setqとsetfの速度差
ついでに見つけた速度の差らしきものが面白かったのでメモ
(defun foo (count) (let (qtime ftime i) (dotimes (j 2) (setq qtime (si:performance-counter)) (dotimes (k count) (setq i k)) (setq qtime (- (si:performance-counter) qtime))) (dotimes (j 2) (setq ftime (si:performance-counter)) (dotimes (k count) (setf i k)) (setq ftime (- (si:performance-counter) ftime))) (format t "setq(count ~A): ~@10A (AVG: ~@5A)~%setf(count ~A): ~@10A (AVG: ~@5A)~%" count qtime (truncate (/ qtime count)) count ftime (truncate (/ ftime count))))) (foo 10000) setq(count 10000): 270629 (AVG: 27) setf(count 10000): 8047492 (AVG: 804) (compile 'foo) (foo 10000) setq(count 10000): 5574 (AVG: 0) setf(count 10000): 5501 (AVG: 0)
from http://pc7.2ch.net/test/read.cgi/software/1143621919/920