+1 for making an inlined version of #timesRepeat:

Sometimes speed matters, and for someone coming from an environment where it's faster than #to:do: it might not be so easy to detect where the unexpected time penalty came from.

Unfortunately, I'm not sufficiently familiar with the Compiler/Decompiler to volunteer to do it myself :-p

And to answer C�drick's question, browsing senders of a method should tell you if it's inlined of not. In VA there are no senders of #timesRepeat: or #to:do, although both are used extensively.

In case anyone is interested, here is the complete list of inlined methods in VA

#== #~~ #and: #ifFalse: #ifFalse:ifTrue: #ifTrue: #ifTrue:ifFalse: #isNil #not #notNil #or: #timesRepeat: #to:do: #whileFalse: #whileTrue:

How does it compare to Pharo?

--
Cheers,
Peter

2009/11/13 C�drick B�ler <cdrick65@gmail.com>
Thanks all.

Interesting. I saw by using tallySends that:

timesRepeat:
This simulation took 6.0 seconds.
**Tree**
1 SmallInteger(Integer)>>timesRepeat:

**Leaves**
100001 UndefinedObject>>DoIt
1 SmallInteger(Integer)>>timesRepeat:
��������� 1 UndefinedObject>>DoIt


to:do:
This simulation took 3.0 seconds.
**Tree**

**Leaves**
1 UndefinedObject>>DoIt


I guess this is one consequence of being inlined.


This makes ask another questions:

-how to know what's inlined, what method have suche properties (a comment would be cool, so if we had to choose...) ?
-how to add Compiler inlining rules (as it's easy ;) ) ?
-why not inlining timesRepeat: (as I guess we don't really change it often) ?


Thanks.

ps: the result is slow because I used a 5 year old (at least) computer :). I think I got a 10x difference in a 2 year one...


2009/11/13 Nicolas Cellier <nicolas.cellier.aka.nice@gmail.com>
There is also a difference between:


[self atEnd ifTrue: [^nil].
self next.
true] whileTrue.

and:

[self atEnd ifTrue: [^nil]
self next] repeat.

Warning: it's quite easy to add Compiler inlining rules, a bit tougher
to add corresponding Decompiler tricks.

2009/11/13 Marcus Denker <denker@acm.org>:
>
> On Nov 13, 2009, at 9:51 AM, C�drick B�ler wrote:
>
>> Hi,
>>
>> I noticed quite a difference between the two method who "looks" the same to me. Is it normal ?
>>
>
> Normal. to:do: is lnlined (compiled as jumps in the bytecode), whereas timesRepeat: is a message
> send with a closure activation.
>
> � � � �Marcus
>
> fun is the difference between:
>
> � � � �(1 to : 10000) do:
> and
> � � � �1 to: 10000 do:
>
> one is compiled to jumps, the other not and in addition creates a temp collection.
>
> � � � �Marcus
>
>
>
>> I use a rc image (haven't tested in squeak). And it's the same on windows and linux.
>>
>> count := 0.
>> [1 to: 10000000 do: [:i | count :=count + 1]] timeToRun." 677"
>> count := 0.
>> [10000000 timesRepeat: [count := count + 1]] timeToRun" 2571"
>>
>> If not normal, I'll open a issue.
>>
>> Thanks
>>
>> --
>> C�drick
>> _______________________________________________
>> Pharo-project mailing list
>> Pharo-project@lists.gforge.inria.fr
>> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> Pharo-project@lists.gforge.inria.fr
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



--
C�drick

_______________________________________________
Pharo-project mailing list
Pharo-project@lists.gforge.inria.fr
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project



--
Cheers,
Peter