On Sat, Nov 10, 2012 at 8:18 PM, Nicolas Cellier < nicolas.cellier.aka.nice@gmail.com> wrote:
Maybe pre-allocate the right size:
ByteArray new: byteArray size * 16 streamContents: ...
Well, actually we are trying to do a streaming API for a compressor. So, 1) I don't exactly know the number "16" before hand and 2) doing that is exactly what we are trying to avoid (compress/decompress all together). Instead, we are doing some kind of streaming, compressing in blocks of say 1MB. But I was completely surprised when I saw the results.... So there is nothing easy to improve? Nicolas
2012/11/10 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi guys:
|byteArray| byteArray := (ByteArray new: 1024*1024). [ ByteArray streamContents: [:s | 16 timesRepeat: [ s nextPutAll:byteArray ] ] ] timeToRun
Gives me around 1 second. Isn't that too much? or is it normal/expected? Anything I could improve?
Thanks,
-- Mariano http://marianopeck.wordpress.com
-- Mariano http://marianopeck.wordpress.com