Writing a large Collection of integers to a file fast
André Wendt
andre.wendt at hpi.uni-potsdam.de
Sat Jan 26 15:57:16 UTC 2008
Lukas Renggli wrote:
>> Oe possible optimization is to not use the #, message because it
>> create a copy of the String.
>> So you can try:
>>
>> aFile := CrLfFileStream fileNamed: aFilename.
>> aLargeCollection do: [ :int |
>> aFile nextPutAll: int printString; nextPut: Character cr.
>> ].
>> aFile close.
>
> Or even smarter:
>
> aStream print: int; nextPut: Character cr
>
> Lukas
Thanks for your suggestions! I've tried, but it didn't give the boost I
was hoping for...
André
>> On Jan 26, 2008, at 12:37 PM, André Wendt wrote:
>>
>>> Hi,
>>>
>>> I'm looking for a fast way to write a large Collection of ints (over 6
>>> million elements) to a file. My attempt was:
>>>
>>> aFile := CrLfFileStream fileNamed: aFilename.
>>> aLargeCollection do: [ :int |
>>> aFile nextPutAll: int printString, String cr.
>>> ].
>>> aFile close.
>>>
>>> Unfortunately, this takes more than fifteen minutes. I suspect this is
>>> due to my implementation.
>>>
>>> Is there any smart way I can do this faster?
>>>
>>> Thanks,
>>> André
>>>
>> Mth
More information about the Squeak-dev
mailing list
|