On 1/16/2015 12:55 PM, Nicolas Cellier wrote:
2015-01-16 0:48 GMT+01:00 Jimmie Houchin <[email protected] <mailto:[email protected]>>:

    Hello,

    Yes, I understand this is a micro-benchmark. And yes I know that
    micro-benchmarks can be dangerous and sometimes worthless.
    However, financial trading, which is the app I am working on, does
    this a lot. This is precisely where most of the time is spent.
    Adding data (numbers) or accessing data in arrays or matrices.
    This is where my app lives. And performance is important.

    Regarding my running of the test and the variety of loop sizes.
    From what I see in the test there is only one loop size. 10000
    There are differing initial OrderedCollection sizes. Unless I am
    misreading the code.

    OrderedCollection new: 100.   (capacity 100).

    I don't understand how this could be a capacity of 100 by what
    seems to me to be a normal understanding when its initial size is
    0 and it can grow infinitely beyond 100.

    To me if it has a capacity of 100, immediately after creation its
    size should be 100
    and its initial 100 elements should be accessible.
    oc at: 1 put: 1        should work.
    So I do not understand where this supposed capacity enters into
    anything. It is neither immediately accessible, nor does it limit.


It's not specific to OrderedCollection.
Dictionary new: 100 and Set new: 100 also behave the same.

It's rather Array that behaves differently than the rest of Collection zoo, because an Array of capacity 100 is also an Array of size 100, same for other ArrayedCollection.

So if you re-think of it, you should always understand new: as reserving a certain capacity, which can casually also result in a collection of same size.

You should notice the #ofSize: message that was added once upon a time...

Yes, after writing the email when I went back into the image and browsed OrderedCollection, I saw the #ofSize: message which does exactly what I naively thought #new: would do.

I ran the tests with #ofSize: and #at:put: and got a reasonably nice improvement over any of the #new: implementations. It wasn't anywhere near the tests done using an Array, but better.

Dictionaries and Sets are very different creatures from Array and OrderedCollection. An OrderedCollection could just as easily be named GrowableArray or some such. At least from my understanding.

So, yes, I need to change my naive understanding to a now slightly better informed understanding.
There is much to learn.

Thanks for your input.

Jimmie

Reply via email to