Subject: [clisp-list] Re: fastest (character) based io with CLISP? - unicode is fast, p osition dead slow

From: "Hoehle, Joerg-Cyril" <[email-masked]>
Date: Fri Feb 7 08:41:02 2003

Sam wrote:
>> Is character-based i/o much slower than using (unsigned-byte 8)
>> (i.e. should I work on ASCII codes, emulate read-line etc.?
>probably not.

You are right, I did a loop on READ-BYTE-SEQUENCE and (POSITION 13 buffer) with and without EXT:convert-string-from-bytes.

Times are almost the same, but GC is 100MB more (filesize 50MB).

;-- only position, without convert-from-bytes
Real time: 36.578 sec.
Run time: 36.21875 sec.
Space: 266932 Bytes
  ||
;-- using convert-string-from-bytes
Real time: 38.797 sec.
Run time: 38.234375 sec.
Space: 102_593_868 Bytes
GC: 12, GC time: 0.234375 sec.

Note that without POSITION, I'd have huge speed improvements. Doing only READ-BYTE-SEQUENCE, I obtain:
Real time: 2.375 sec.
Run time: 2.140625 sec.
Space: 70324 Bytes
  ||
and READ-BYTE-SEQUENCE with convert-string-from-bytes:
Real time: 4.297 sec.
Run time: 3.96875 sec.
Space: 101270288 Bytes
GC: 154, GC time: 0.3125 sec.

2 seconds unicode conversion overhead for 50MB of data is really acceptable. Generational GC makes throwing out 100MB of garbage acceptablably fast (I got a very different training a decade ago using CMUCL stop&copy GC).

So maybe (EXT:STRING-POSITION character string :start :end) would be welcome?

or EXT:POSITION-IN-STRING or POSITION-WITHIN-STRING or ??

>the two obvious alternatives:
[...]
>are about half as fast (take twice as much time!) as your version, but
>do almost no consing.
I thought I also posted a READ-BYTE-SEQUENCE loop, not using POSITION, with results in the order of 2-3 seconds?

>(still faster that ACL 6.2!)
Good news, but still not 1/10 the time of the perl program I'm targetting. If I only get 1/2 or 1/3 the perl speed, it's not impressive.

Thanks and regards,
	Jorg Hohle.