Writing a large Collection of integers to a file fast
Mathieu Suen
mathk.sue at gmail.com
Sat Jan 26 11:45:32 UTC 2008
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.
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
|