The breaking point seems to be around 5 concatenations:
str:= Character alphabet.
[ str, str, str, str, str ] bench.
"'1,020,043 per second'"
[ String new: str size * 5 streamContents: [ :out | 5 timesRepeat: [ out
nextPutAll: str ] ] ] bench.
"'949,738 per second'"
> On 13 Mar 2015, at
> On 13 Mar 2015, at 08:41, stepharo wrote:
>
> use
>
> String streamContents: [:s |
>s nextPutAll: 'jlklkjkl' ]
>
>
> or
>
> String streamContents: [:s |
>s << 'jlklkjkl' ]
>
>
> it is a great method for manipulating
>
> Le 10/3/15 19:09, sergio_101 a écrit :
>>
>> it seems that
use
String streamContents: [:s |
s nextPutAll: 'jlklkjkl' ]
or
String streamContents: [:s |
s << 'jlklkjkl' ]
it is a great method for manipulating
Le 10/3/15 19:09, sergio_101 a écrit :
it seems that in more cases than not, i find that developers use a
stream when concatenating
it seems that in more cases than not, i find that developers use a stream
when concatenating some text strings.
I am wondering if this is a smalltalk thing, or is there a real speed
benefit when using streams in this way.
Thanks!
Andres Valloud performed some benchmarking in the past and his conclusion
was that there was a threshold higher than expected when the streamed
concatenation was faster and memory savvier. This was years ago, and of
course I don't remember such threshold.
However from the code aesthetics I use sim
There are a few things floating around the web saying that it is faster
using a stream for concatenation, but its been shown a while back to be
"not necessarily" true. It depends on the use case so you should profile -
if its that important.
cheers -ben
On Wed, Mar 11, 2015 at 2:09 AM, sergio_101
gotcha.. this makes sense.
On Tue, Mar 10, 2015 at 2:18 PM Esteban A. Maringolo
wrote:
> 2015-03-10 15:09 GMT-03:00 sergio_101 :
> >
> > it seems that in more cases than not, i find that developers use a stream
> > when concatenating some text strings.
> >
> > I am wondering if this is a smallta
2015-03-10 15:09 GMT-03:00 sergio_101 :
>
> it seems that in more cases than not, i find that developers use a stream
> when concatenating some text strings.
>
> I am wondering if this is a smalltalk thing, or is there a real speed
> benefit when using streams in this way.
It is not a matter of sp