
Fixed-length strings are slow, especially long ones.
It happens that NadCixelsyd formulated :
Quote:
> I read a binary file with multiple GETs into a string. If the buffer
> is "DIM SBUFFER AS STRING * 60000", it takes 500-600 "GET #176,
> bufloc, SBUFFER" to read a 30 megabyte file. It takes about 8 seconds
> to do so.
> If I shrink the buffer size (say to 30000), the number of GETs
> increases (as expected), but the elapsed time is reduced to about 5
> seconds.
> If, on the other hand, I specify, "DIM SBUFFER AS STRING" to create a
> dynamic string, thence "SBUFFER = SPACE$(60000)" to set the buffer
> size, the 500-600 GET statements now take less than two seconds. The
> elapsed time is pretty much the same regardless of the string's
> length.
> I would have thought that it would be the other way around.
Well, wrong. As you found. Fixed length strings are an anachronism.
But then, so are strings (period!) for file i/o. About 15 years ago,
Unimess changed everything. You should only use byte arrays for this
sort of activity.
--
.NET: It's About Trust!
http://vfred.mvps.org