Writing a large Collection of integers to a file fast
bert at freudenbergs.de
Sat Jan 26 16:23:29 UTC 2008
On Jan 26, 2008, at 16:57 , André Wendt wrote:
> 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
> Thanks for your suggestions! I've tried, but it didn't give the
> boost I
> was hoping for...
Try printing to a memory buffer in chunks of 10000 integers, and
putting that on the file. Unbuffered I/O is slow.
If that's still not enough (or even before), profile.
- Bert -
More information about the Squeak-dev