>
> When I open a 34 K file and read characters, I get the following
> performance (this is on an HP 9007s715):
>
> (time (let ((ch (read-char port)))
> (while (not (eof-object? ch)) (set! ch (read-char port)))))
>
> ;; Time: 1520.00ms
> ;; GC time: 110.00ms
> ;; Cells: 68082
>
>
> This is about 22K/second. A C program that uses fopen and getc on
> the same machine gives about 2Mb/second.
>
> Is a 100 time slow-down to be expected? Is there any way to speed
> this up by changing buffering, etc?
>
> It appears that my program is spending most of its time
> in (peek-char ..) and (read-char ..)....
>
> Thanks for any advice...
> Drew
>
Is there an counterindication for a line per line read ?
this will usually greatly speed up things, although it may make
parsing more difficult.
On my machine reading the same file is 20 time faster using read-line
instead of read-char.
Hopes it may help
Marc
STk> (time (let ((ch (read-char port)))(while (not (eof-object? ch))
(set! ch (read-char port)))))
;; Time: 683.33ms
;; GC time: 50.00ms
;; Cells: 44774
STk> (time (let ((l (read-line port))) (while (not (eof-object? l))
(set! l (read-line port)))))
;; Time: 33.33ms
;; GC time: 0.00ms
;; Cells: 323
--
Furrer Marc EPFL DI-LTI, 1015 Lausanne, Suisse
Marc.Furrer_at_di.epfl.ch +41 21 693 29 07 / 66 00 (Fax)
http://ltiwww.epfl.ch/~furrer
--
You are a wise man my friend.
Not yet sir. But with your help, I am learning.
-- Riker and Data, "The Measure of a Man", stardate 42523.7
--
PGP 2.6 encrypted mail are welcomed, public key on nearest server
Received on Thu Apr 13 1995 - 15:40:18 CEST