[Pharo-project] Basic tricks for improving a serializer?
Mariano Martinez Peck
marianopeck at gmail.com
Wed May 18 08:29:42 EDT 2011
On Tue, May 17, 2011 at 3:34 PM, Sven Van Caekenberghe <sven at beta9.be>wrote:
> On 17 May 2011, at 15:21, Mariano Martinez Peck wrote:
> > Now Igor told us for example, to use a buffer like this:
> > | bufferStream |
> > bufferStream := ByteArray new writeStream.
> > (FLSerializer on: bufferStream)
> > serialize: anArrayToSerialize.
> > aFileStream nextPutAll: bufferStream contents.
> > and that it at least 2 times faster than we were doing.... I guess it is
> because it goes to the disk only once. But MultiByteFileStream uses a
> buffer, doesn't it ?
> The disadvantage of the above is that you buffer everything before you
> write. Furthermore you are growing the buffer all the time (recopying
> contents) which is not too efficient.
> Some time ago we had a discussion about this and then I implemented
> ZnBufferedWriteStream (it should be in Core 1.3), have a look. It was just a
> quick hack, but it worked in speeding up writing.
Sven, I improved quite a lot using your buffered write stream. What I don't
understans is why MultiByteFileStream doesn't perform as good as them.
If I see StandardFileStream has an internal buffer called 'buffer1'.
So why is that much difference between using MultiByteFileStream directly
and a WriteStream (ByteArray new writeSteam ) or ZnBufferedWriteStream ?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-dev