[Newbies] Efficiently writing to a file

Ian Oversby oversby at googlemail.com
Tue Apr 10 21:50:42 UTC 2007


On 10/04/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
>
> On Apr 10, 2007, at 23:22 , Ian Oversby wrote:
>
> > Okay, I tried this and it still seems a bit slow:
> >
> > | myFile ios |
> >
> > ios := ReadWriteStream on: ''.
> >
> > Transcript show: 'Populate Buffer: ',
> >       (Time millisecondsToRun: [
> >               1 to: 10000 do: [
> >                       :x | ios nextPutAll: ((x asString) , String crlf)
> >                       ]]) asString , ' millseconds' ; cr.
> >
>
> >  Is this the correct way to use the stream?
>
> Why not write
>
>         1 to: 10000 do: [:x | ios print: x; cr]
>
> - Bert -

I don't know the difference between print: and nextPutAll:, but cr
didn't put the correct line ending for Windows, and it still seems
equally slow.

Ian


More information about the Beginners mailing list