[Gambas-user] What is faster: OPEN or File.Load?

Rolf-Werner Eilert eilert-sprachen at ...221...
Mon May 30 10:47:12 CEST 2011


Am 27.05.2011 12:33, schrieb Benoît Minisini:
>>> When I have different directories which contain text files, and I have
>>> to open each file and read only the first line of it, which one will be
>>> faster and more efficient:
>>>
>>> FOR
>>>
>>> 	OPEN
>>> 	
>>>     		read first line
>>> 	
>>> 	CLOSE
>>> 	list.Add
>>>
>>> NEXT
>>>
>>> or
>>>
>>> FOR
>>>
>>> 	File.Load(...)
>>> 	Split(... chr$(10))
>>> 	list.Add(...)
>>>
>>> NEXT
>>>
>>> Or wouldn't that be feasible in case of, say, 50 - 70 files in such
>>> directories?
>>>
>>> Thanks for your comments :-)
>>>
>>> Rolf
>>
>> The second one is obviously faster. Just check the execution time!
>>
>> Regards,
>
> Oops, sorry, I didn't see that you wanted just the first line. Then the first
> one will be faster, unless you have very small files.
>
>
> Regards,
>

Well, I want both... First I simply need the complete list of names 
(first line only), later I have to look into each file to find data. So 
I will use both ways, thank you!

Rolf





More information about the User mailing list