[squeak-dev] The Trunk: Files-ul.108.mcz

Eliot Miranda eliot.miranda at gmail.com
Tue Apr 26 18:15:00 UTC 2011


On Tue, Apr 26, 2011 at 10:59 AM, Levente Uzonyi <leves at elte.hu> wrote:

> On Tue, 26 Apr 2011, Chris Muller wrote:
>
>  Why do that from the sender?  Symbol>>#= already checks via == in the
>> first two lines..
>>
>
> It's faster, because there's no method lookup, no message send, no
> suspension point. The commit message is misleading, because all, but the
> last comparison in this loop is done between a Symbol and an Array. So in
> almost all cases it saves 3 message sends, while in the last case it saves
> one.
> Actually I don't expect that it saves that much of total runtime, but why
> not use this property of Symbols and have better performance for free?
>

Especially when the difference (on current Cog) is two orders of magnitude:

| n b1 b2 |
n := 1000000.
b1 := [1 to: n do: [:i| #Symbol == nil. #Symbol == nil. #Symbol == nil.
#Symbol == nil. #Symbol == nil. #Symbol == nil. #Symbol == nil. #Symbol ==
nil. #Symbol == nil. #Symbol == nil]].
b2 := [1 to: n do: [:i| #Symbol = nil. #Symbol = nil. #Symbol = nil. #Symbol
= nil. #Symbol = nil. #Symbol = nil. #Symbol = nil. #Symbol = nil. #Symbol =
nil. #Symbol = nil]].
{ b1 timeToRun. b2 timeToRun.
  b1 timeToRun. b2 timeToRun.
  b1 timeToRun. b2 timeToRun } #(12 885 12 881 10 884)


>
> Levente
>
>
>> - Chris
>>
>>
> snip
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20110426/e6a925d8/attachment.htm


More information about the Squeak-dev mailing list