[Pharo-project] Basic tricks for improving a serializer?
Mariano Martinez Peck
marianopeck at gmail.com
Tue May 17 21:57:07 CEST 2011
Sven, I want to make it work :)
so....the missing methods I told you that I need are:
Implement #contents I guess it is something like:
ZnBufferedWriteStream >> contents
^ stream contents
Those missing methods I need are implemented PositionableStream. I took the
implementation from there and put it in ZnBufferedWriteStream.
I just added to them a first line " self flushBufferIfFull."
The way I am creating it is like this:
stream := ZnBufferedWriteStream on: ((FileDirectory default
forceNewFileNamed: 'mariano') binary).
So...is this correct Sven? My tests are green :)
Still need to try benchmarks.
On Tue, May 17, 2011 at 8:18 PM, Mariano Martinez Peck <
marianopeck at gmail.com> wrote:
> 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.
> Thanks Sven, what a great point you gave me. I tried it a little and I
> found a couple of methods missing which I used to use for a normal
> I will play a little more when I have time and I will ask you again!!
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Pharo-project