chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Is there interest in a new egg (fast-io)?


From: Jim Ursetto
Subject: Re: [Chicken-users] Is there interest in a new egg (fast-io)?
Date: Thu, 22 Apr 2010 14:25:00 -0500


On Apr 6, 2010, at 9:34 AM, Jeronimo Pellegrini wrote:

BTW, I've benchmarked complex reading ad writing too. I suppose
the difference is huge for reading complexes because the read
procedure doesn't know that it's a complex number.

Hi there.  Your numbers looked odd to me so I downloaded
and ran your benchmarks.  I believe you got such poor
performance on reads due to (use numbers).

Here are your numbers again:

               scheme    fast-io   speedup
-------------------------------------------
write fixnum    14.602      5.303    2.7535
read  fixnum    58.208     11.706    4.9725

write flonum    37.003     21.647    1.7094
read  flonum   100.367     15.626    6.4231

write complex   89.361     56.020    1.5952
read  complex 3076.952     59.476    51.734
-------------------------------------------

Here are my numbers:

            scheme  fast-io  line  numbers 1.8   2.1
------------------------------------------------------
write fixnum    26       21    26           26
read  fixnum    61       20    22          211   193
write flonum    48       25    48           50
read  flonum    86       24    25          276   246

where
"scheme" is your code without numbers loaded,
"fast-io" is your fast-io code,
"numbers" is your code with numbers version 1.8 or 2.1 loaded,
"line" is my fast scheme implementation.

CPU performance disparity aside, I don't get nearly the
slowdown that you do with plain scheme (read), so my guess is
that either you loaded the numbers egg or that fast-io
is inexplicably slow on my machine.  I presume you
loaded numbers because your complex test did not work
without it.

Furthermore the "line" implementation is basically on par
with fast-io, as long as numbers is not loaded.

To get the "line" implementation for readers all you need to do
is replace (read port) with (string->number (read-line port)).
Furthermore when you generate the files, use a newline
delimiter instead of a space.

"line" is faster than "scheme" by 3-4x because read is
more general and more importantly, because (read)
is character based and char-based I/O from stream ports
is really slow on Chicken.  On the other hand, line and string
based I/O is fast.

Based on this admittedly quick test, there's not much
advantage to using fast-io as long as your data is
newline-delimited.

What might be useful is a read-delimited-string (or whatever)
which would read until a specified set of delimiters.
This wouldn't replace read-line--as newlines are handled
specially due to \r--nor would it handle escaped chars,
but it would handle the basic case of reading strings until
NUL or SPACE.

Or you could preprocess your space-delimited files with
 tr ' ' '\012'
:)

Jim





reply via email to

[Prev in Thread] Current Thread [Next in Thread]