[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: string vs list processing
From: |
Sascha Ziemann |
Subject: |
Re: string vs list processing |
Date: |
16 Apr 2001 15:56:16 +0200 |
User-agent: |
Gnus/5.0803 (Gnus v5.8.3) Emacs/20.6 |
Sascha Ziemann <address@hidden> writes:
| The following example compares string-ref directly with list-ref:
|
| (let* ((str (string-append (list->string (make-list 1000 #\A))))
| (lst (string->list str))
| (len (1- (length lst)))
| (len/2 (quotient len 2)))
| (compare-run-time 100000
| (string-ref str 0)
| (list-ref lst 0)
| (string-ref str len/2)
| (list-ref lst len/2)
| (string-ref str len)
| (list-ref lst len)))
| ;; 1.21 seconds for 100000 times (string-ref str 0)
| ;; 1.24 seconds for 100000 times (list-ref lst 0)
| ;; 1.24 seconds for 100000 times (string-ref str len/2)
| ;; 1.88 seconds for 100000 times (list-ref lst len/2)
| ;; 1.22 seconds for 100000 times (string-ref str len)
| ;; 2.58 seconds for 100000 times (list-ref lst len)
The calculation was not fair. I removed the time spend for the
iterations and now the result looks different:
;; 0.35 seconds for 100000 times (string-ref str 0)
;; 0.34 seconds for 100000 times (list-ref lst 0)
;; 0.37 seconds for 100000 times (string-ref str len/2)
;; 1.03 seconds for 100000 times (list-ref lst len/2)
;; 0.36 seconds for 100000 times (string-ref str len)
;; 1.74 seconds for 100000 times (list-ref lst len)
But I think avoiding string functions is still a good idea.
bis später...
Sascha
--
Ein Hoch auf den 7. Juni 2000
Re: string vs list processing, Masao Uebayashi, 2001/04/16