[mew-dist 22283] Re: accelerating by-folder

Kazu Yamamoto ( 山本和彦 ) kazu at example.com
2002年 11月 15日 (金) 15:39:59 JST


From: Hideyuki SHIRAI (白井秀行) <shirai at example.com>
Subject: [mew-dist 22279] Re: accelerating by-folder

> 以前聞いた話だと、扱う list の長さが 10ぐらいまでは mapcar の方
> が速いけど、それ以上なら while の方が速い、らしいとのことです。

最後に添付したコードで実験してみました。

----
Function Name  Call Count  Elapsed Time  Average Time
=============  ==========  ============  ============
my-test2       1           0.071404      0.071404
my-test        1           0.062207      0.062207
my-while       10          0.07089       0.007089
my-mapcar      10          0.0617159999  0.0061715999
----

mapcar の方が速いです。でも、誤差なのでメモリー消費量の少ない、while 
の方が総合的にはよいと思われます。

しかしながら、IMAP などのことも考えると、mew-local-folder-alist だけを
検査するのでは不十分だと分ったので、やっぱり mew-use-fast-refile を手
で設定してもらうことにします。

--かず

----
(defun my-test ()
  (let ((alist (mew-local-folder-alist))
	(i 0))
    (while (< i 10)
      (my-mapcar alist)
      (setq i (1+ i)))))

(defun my-mapcar (alist)
  (let ((case-fold-search nil)
	found)
    (catch 'break
      (mapcar (lambda (x)
		(cond
		 ((and (stringp (cdr x)) (string-match "[A-Z]" (cdr x)))
		  (throw 'break (setq found (cdr x))))
		 ((and (stringp (car x)) (string-match "[A-Z]" (car x)))
		  (throw 'break (setq found (car x))))))
	      alist))
    found))

(defun my-test2 ()
  (let ((alist (mew-local-folder-alist))
	(i 0))
    (while (< i 10)
      (my-while alist)
      (setq i (1+ i)))))

(defun my-while (alist)
  (let ((case-fold-search nil)
	x found)
    (catch 'break
      (while alist
	(setq x (car alist))
	(setq alist (cdr alist))
	(cond
	 ((and (stringp (cdr x)) (string-match "[A-Z]" (cdr x)))
	  (throw 'break (setq found (cdr x))))
	 ((and (stringp (car x)) (string-match "[A-Z]" (car x)))
	  (throw 'break (setq found (car x)))))))
    found))
----



Mew-dist メーリングリストの案内