[squeak-dev] The Inbox: Collections-nice.807.mcz
David T. Lewis
lewis at mail.msen.com
Sun Sep 16 02:25:01 UTC 2018
On Sat, Sep 15, 2018 at 06:35:52PM -0700, Bert Freudenberg wrote:
> On Sat, Sep 15, 2018 at 4:58 PM Levente Uzonyi <leves at caesar.elte.hu> wrote:
>
> > Hi Eliot,
> >
> > Here is a very simple test case:
> >
> > {
> > [ 1 to: 500000000 do: [ :i | i = 1 ifTrue: [ true ] ifFalse: [
> > false ] ] ] timeToRun.
> > [ 1 to: 500000000 do: [ :i | i = 1 ] ] timeToRun.
> > }
> >
> > On my machine it gives #(992 1436).
> >
>
> Huh, interesting.
>
> Eliot, if you figure this out, please let us know what it was ...
>
> - Bert -
On my machine with cog/spur 64 bit I see this:
{
[ 1 to: 500000000 do: [ :i | i = 1 ifTrue: [ true ] ifFalse: [false ] ] ] timeToRun.
[ 1 to: 500000000 do: [ :i | i = 1 ] ] timeToRun.
[ 1 to: 500000000 do: [ :i | true ] ] timeToRun.
[ 1 to: 500000000 do: [ :i | ] ] timeToRun.
} ==> #(859 1576 921 922)
On the same machine with context interpreter 64-bit VM 32-bit image, it is:
{
[ 1 to: 500000000 do: [ :i | i = 1 ifTrue: [ true ] ifFalse: [false ] ] ] timeToRun.
[ 1 to: 500000000 do: [ :i | i = 1 ] ] timeToRun.
[ 1 to: 500000000 do: [ :i | true ] ] timeToRun.
[ 1 to: 500000000 do: [ :i | ] ] timeToRun.
} ==> #(8806 8816 5547 5554)
It looks like the first block with #ifTrue:ifFalse: may be benefiting
from a Cog optimization that the other three cases do not receive.
It's interesting that the optimized block containing #ifTrue:ifFalse:
is actually faster than an empty block that does nothing at all.
Dave
More information about the Squeak-dev
mailing list
|