Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Line Input vesus array

1 view
Skip to first unread message

C. Kevin Provance

unread,
Dec 26, 2009, 2:45:16 PM12/26/09
to
Question:

I have a bunch of old code that uses Line Input to read data from text files
one line at a time via a loop (and then does whatever it needs to do with
that data)

Recently I've started reading the entire file into a string and using Split
to put all the line data into an array, and then For/Next through the array.

I can't really see a performance issue one way or the other. Does anyone
know which method is considered faster and/or more effective? Or is it
negligible?

Were not talking about huge amounts of data. At the most some files may
have fifty or so lines of data...most considerably less.

- Kev


Ralph

unread,
Dec 26, 2009, 5:45:43 PM12/26/09
to

"C. Kevin Provance" <*@*.*> wrote in message
news:up1RyPmh...@TK2MSFTNGP04.phx.gbl...

Not sure I would say "negligible", as one gulp is usually a few clicks
faster, but for small gulps - certainly gets close.

In general one gulp and split() is the fastest method - but you have to
start chewing on large files or do a ton in a row to see a practical
difference.

There used to be a clear difference between reading lines or grabbing
everything, because the File I/O buffer sizes were relatively small and it
was a more deterministic process. Since Win2k the way the O/S maps files and
services individual requests changed dramatically. So even if you test, you
can expect your tests to vary depending on load, multiple files, etc.

-ralph


Schmidt

unread,
Dec 26, 2009, 8:16:30 PM12/26/09
to

"C. Kevin Provance" <*@*.*> schrieb im Newsbeitrag
news:up1RyPmh...@TK2MSFTNGP04.phx.gbl...

In addition to Ralph - the speed-difference is negligible on
such small sets of data (< 1-3kByte) - it will become larger,
if you need to handle Files > 10kByte - and the:
"read the whole file + work on the content afterwards"-
is the more "portable" approach, compared with the very
Basic-specific "special File-Reading or Writing-routines".

Reading Raw-bytes from a File or a Stream into a
String (or a ByteArray) - and then processing the content
with the usual Stringhandling-routines (splitting, filtering,
parsing, "regexing" or whatever) is pretty indentical over
a lot of languages - so, if you have no special preference -
I'd go with the not all that "specific" File-Handling-stuff.

Olaf


0 new messages