My app imports/exports text files to the PC using a Conduit.  It's a pretty
simple implementation that is very fast.  I then wanted to add the ability
to convert text files directly on the device by importing/exporting the same
text files to the expansion Card for when users were away from their
conduit.  To do this, I simply ported my Conduit code to my App and switch
the file stream calls with VFS calls.  Everything went well except its
*much* slower than the Conduit.  E.g., the conduit takes a few seconds to
convert a 256K file, by my VFS/Card implementation takes 5 minutes or so to
convert the same file.

The nature of the text files is that each line tends to only have a dozen
characters or so, and there are usu. thousands of lines.  When importing the
file, I simply read a line at a time and process it.  With my conduit, I
used fgets().  I didn't see a VFS/fgets() function, so I wrote a very simple
one that reads the file a character at a time, using VFSFileRead, into a
buffer and returns the buffer when a NULL is hit.  Likewise, I didn't see an
fprintf(), so I wrote a quick function to output a string to the Card using
VFSFileWrite (it writes the whole string, not a character at a time).

I'm starting to think that it's so slow because of too may file access
calls.  E.g., instead of reading a character at a time, I should read 1K
characters into a buffer and then process them.  Likewise, instead of
writing my short strings I should buffer them and write out 1K at a time.

I haven't implemented this yet, mostly because I'm wondering if this is the
most optimal approach.  If anyone knows of an faster implementation, I'd
appreciate hearing it.

Thanks!
Rich


-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to