Subject: Re: string -> list
From: Erik Naggum <erik@naggum.no>
Date: 1998/10/04
Newsgroups: comp.lang.lisp
Message-ID: <3116511818742521@naggum.no>

* Marc Dzaebel <marc@rose.de>
| Following times have been measured on ACL5.0/Linux/200/PC
| 
| (defun test1()
|  (time(dotimes(n 100000)(coerce"abc"'list))))
| (compile'test1)
| (test1)
| ; cpu time (non-gc) 190 msec user, 0 msec system (ACL5.0/Linux/200)
| 
| (defun test2 ()
|  (time(dotimes(n 100000)(loop for c across "abc" collect c))))
| (compile'test2)
| (test2)
| ; cpu time (non-gc) 470 msec user, 0 msec system (ACL5.0/Linux/200)

  I don't believe your 190 ms figure.

  the following timings are from ACL 5.0 running under Linux 2.0.35 on an
  old 133MHz Intel Pentium II, best figures from three consecutive runs:

(defun test1 ()
  (time
   (dotimes (n 100000)
     (coerce "abc" 'list))))
; cpu time (non-gc) 990 msec user, 0 msec system
; cpu time (gc)     180 msec user, 0 msec system
; cpu time (total)  1,170 msec user, 0 msec system
; real time  1,168 msec
; space allocation:
;  300,000 cons cells, 0 symbols, 0 other bytes, 0 static bytes

(defun test2 ()
  (time
   (dotimes (n 100000)
     (loop for c across "abc" collect c))))
; cpu time (non-gc) 520 msec user, 0 msec system
; cpu time (gc)     80 msec user, 0 msec system
; cpu time (total)  600 msec user, 0 msec system
; real time  604 msec
; space allocation:
;  400,000 cons cells, 0 symbols, 0 other bytes, 0 static bytes

(defun test3 ()
  (time
   (dotimes (n 100000)
     (map 'list #'identity "abc"))))
; cpu time (non-gc) 430 msec user, 0 msec system
; cpu time (gc)     50 msec user, 0 msec system
; cpu time (total)  480 msec user, 0 msec system
; real time  476 msec
; space allocation:
;  300,000 cons cells, 0 symbols, 0 other bytes, 0 static bytes

(defun test4 ()     
  (time
   (dotimes (n 100000)
     (do ((i 0 (1+ i))
	  (l (length "abc"))
	  (list ()))
	 ((eq i l) (nreverse list))
       (declare (fixnum i l))
       (push (schar "abc" i) list)))))
; cpu time (non-gc) 270 msec user, 0 msec system
; cpu time (gc)     100 msec user, 0 msec system
; cpu time (total)  370 msec user, 0 msec system
; real time  369 msec
; space allocation:
;  300,000 cons cells, 0 symbols, 0 other bytes, 0 static bytes

  note: the extra cons cell allocated in TEST2 comes from the way LOOP
  collects into a list.

#:Erik