Path: titcca!ccut!kyu-cs!champon!umerin From: umerin@tc.Nagasaki.GO.JP (Masanobu UMEDA) Newsgroups: fj.lang.lisp Subject: Re: CLOS performance. (In Japanese/Kanji) Message-ID: Date: 30 Mar 90 06:00:33 GMT References: Sender: news@tc.nagasaki.go.jp Reply-To: umerin@tc.Nagasaki.GO.JP Distribution: fj Organization: Technology Center, Nagasaki, Japan. Lines: 50 In-reply-to: yosikawa@ccs.mt.nec.junet's message of 28 Mar 90 03:02:46 GMT In article yosikawa@ccs.mt.nec.junet (Masazumi Yoshikawa) writes: *結論: slot-value より accessor の方が速い. *実験内容: 以下のファイルをコンパイルして,速度を比較した. (defclass c () ((s :accessor accessor :initarg :s))) (defun test-slot-value () (let ((instance (make-instance 'c :s 1))) (dotimes (i 1000) (slot-value instance 's)))) (defun test-accessor () (let ((instance (make-instance 'c :s 1))) (dotimes (i 1000) (accessor instance)))) *データ: (time (test-slot-value)) (time (test-accessor)) run time : 0.533 secs run time : 0.283 secs run time : 0.317 secs run time : 0.217 secs run time : 0.317 secs run time : 0.283 secs run time : 0.350 secs run time : 0.233 secs run time : 0.350 secs run time : 0.217 secs run time : 0.283 secs run time : 0.217 secs OPTIMIZE-SLOT-VALUE に trace を掛けて上のテストプログラムを load/compile してみたのですが,どうも呼ばれてはいないようで す. これは,おそらく,関数 test-slot-value の中の変数 instance がクラス c のインスタンスであるという事実を KCl のコンパイラ または,PCL が知らないためでしょう. 正解です。この場合、私が前の記事で説明した最適化が行なわれません。先ほ どの例を、次のように変更すると、一桁近く高速化されるはずです (Symbolics Genera 7.4i では、そうなりましたが、時間がなくてデータを示 すことができません)。 (defun test-slot-value () (let ((instance (make-instance 'c :s 1))) (test-slot-value-internal instance))) (defmethod test-slot-value-internal ((instance c)) (dotimes (i 1000) (slot-value instance 's))) さて、私は、今日でいよいよ JUNET からさよならですので、この後のディス カッションには参加できません。 さようなら。 -- Masanobu UMEDA umerin@tc.Nagasaki.GO.JP