[futurebasic] Re: [FB] Loading File speed

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : April 1999 : Group Archive : Group : All Groups

From: Rick Brown <rbrown@...>
Date: Wed, 28 Apr 1999 20:30:56 -0500

M Fitzgibbons wrote:

> I use the following FN to load a data file. It loads very quickly (a few
> seconds) on the local HD but across a small network (100Mb/s) it takes
> upwards of a minute. It can't be the network as other programs work
> quite quickly. The data file size approx 600K.
>
> If multiple users try to access the same file it is even slower?

I have experienced exactly the same kind of thing.  I had an application which
needed to copy an entire file over the network.  Using "READ FILE" statements
it took literally _minutes_ to copy a file of a few hundred-K bytes over our
otherwise speedy Ethernet.

The problem was solved by the magic of *asynchronous i/o*.  I rewrote my copy
routine to use the Toolbox "Read" routine rather than FB's READ FILE, and had
it "queue" up to 4 asynchronous read requests at a time.  Immediately my copy
routine became as fast as a "Finder" copy.

In my case it worked because I was copying the whole file and could therefore
grab pieces of it in random order (as long as I re-assembled them in the right
order at the other end).  It's hard to see how to apply that to your
situation, in which things apparently have to be read sequentially.

As a start, try something like this:
1. Read the whole file in one big chunk, using READ FILE (you'll have to
reserve a sufficiently large block of memory to hold the file's contents).
2. Write the big chunk to your local hard disk, as a temporary file.
3. Open the temporary file and read it using your LINE INPUT statements.

This hinges on whether Step 1 makes a significant improvement over reading via
LINE INPUT over the network.  My experience is that it still may be rather
slow--but it may help a little.

- Rick