Re: STk I/O Performance

From: Nick Thompson <>
Date: Thu, 13 Apr 95 00:48 EDT

> (time (let ((ch (read-char port)))
> (while (not (eof-object? ch)) (set! ch (read-char port)))))
> 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?

seems a little high but not outrageous. getc() is a macro so the c
implementation can probably read a character in a handful of instructions.
your loop probably has more scheme opcodes than there are machine
instructions in the C version, and they are much much slower.

> Is there any way to speed
> this up by changing buffering, etc?

it's impossible to do high speed char-at-a-time i/o in an interpreter;
the inner loop (the lexical analyzer) has to be compiled. you might
be able to use the regular expression builtins to accomplish this, but
you still need a way to read in big strings rather than characters.
this is a glaring omission from the scheme standard - does stk have a
way to do this? i'm sure scsh does since it is intended to compete
with perl...

it would be cool to have an interpreter with a table-driven lexical
analyzer built in (perhaps the guts of flex could be incorporated).
the tables could be generated off-line by running flex or on-line by
scheme code.

Received on Thu Apr 13 1995 - 06:54:19 CEST

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST