[ENH] SpeedTalkingStreams
schwa at cc.gatech.edu
schwa at cc.gatech.edu
Sun Aug 24 05:04:35 UTC 2003
from preamble:
"Change Set: FastTalkingStreams
Date: 24 August 2003
Author: Joshua Gargus
This changeset greatly speeds up writing word data onto a
RWBinaryOrTextStream. It also provides default implementations for
#byteSize and #bytesPerElement for variable-sized objects.
I noticed the performance problem when trying to write B3DRotationArrays
onto a ReferenceStream on top of a RWBinaryOrTextStream.
Thanks to Boris Gaertner and Yoshiki Ohshima, who provided the ideas for
this changeset.
Sorry about the name, I couldn't come up with a one as witty as
ZippierStreams.
Test with the following code. The first part is the part that
experiences the speedup, and the second verifies correctness. Note: you
should fileIn the method #bytesPerElement first, because FloatArray
won't understand it otherwise. I got a 30x speed improvement on this
benchmark.
floats _ (1 to: 100000) collect: [:ignore | (101 atRandom / 61 atRandom)
asFloat].
floats _ FloatArray withAll: floats.
binStream := RWBinaryOrTextStream on: ''.
binStream binary.
refStream := ReferenceStream on: binStream.
[refStream nextPut: floats] timeToRun.
refStream close.
contents := binStream contents.
binStream := RWBinaryOrTextStream with: contents.
binStream position: contents size. binStream reset.
refStream := ReferenceStream on: binStream.
[refStream next = floats] assert.
refStream close.
"!
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SpeedTalkingStreams.cs.gz
Type: application/octet-stream
Size: 1619 bytes
Desc: not available
Url : http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20030823/7f35da1d/SpeedTalkingStreams.cs.obj
More information about the Squeak-dev
mailing list
|