The cardinal rule of running benchmarks is to compare apples to apples. You've compared apples to oranges, i.e. an optimized reimplementation of WideString>>hash that eliminates the mapping of codes to characters, against the vanilla Squeak implementation. You need to at least compare the NB implementation against<div>
<br></div><div>WideString methods for comparison</div><div><div><div>fastHash</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| stringSize hash low |</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>stringSize := self size.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>hash := ByteString identityHash bitAnd: 16rFFFFFFF.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>1 to: stringSize do: [:pos |</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>hash := hash + (self wordAt: pos).</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>"Begin hashMultiply"</div><div><span class="Apple-tab-span" style="white-space:pre">                </span>low := hash bitAnd: 16383.</div>
<div><span class="Apple-tab-span" style="white-space:pre">                </span>hash := (16r260D * low + ((16r260D * (hash bitShift: -14) + (16r0065 * low) bitAnd: 16383) * 16384)) bitAnd: 16r0FFFFFFF.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>].</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>^ hash</div><div><span class="Apple-tab-span" style="white-space:pre">        </span></div><div><br></div><div><span class="Apple-tab-span" style="white-space:pre">        </span>| s n |</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>s := (WideString with: (Character value: 16r55E4)) , 'abcdefghijklmno'.</div><div><span class="Apple-tab-span" style="white-space:pre">        </span>n := 100000.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span>{ [1 to: n do: [:i| s fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash]] timeToRun.</div>
<div><span class="Apple-tab-span" style="white-space:pre">        </span> [1 to: n do: [:i| s hash. s hash. s hash. s hash. s hash. s hash. s hash. s hash. s hash. s hash]] timeToRun. }</div><div><br></div><div> #(829 1254)</div>
<div><br></div><div>ASo your measurements tell us nothing about a general comparison of NB against the Squeak VM or Cog. They only demonstrate (unsurprisingly) that a loop summing integers in an array goes PDQ. On the other hand my numbers showed Cog 10x faster than the Squeak interpreter when executing exactly the same bytecode.</div>
<div><br></div><div>best</div><div>Eliot</div></div><div><br></div></div><div><br><div class="gmail_quote">On Fri, May 14, 2010 at 4:13 PM, Igor Stasenko <span dir="ltr"><<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">And besides, if someone would bother implementing a primitive<br>
for hasing the WideString, i doubt that he will go and create<br>
an instances of Character for each indice, and then read its value and<br>
only then use<br>
it for hashing.<br>
So, i don't think this is cheating. Its just an optimization :)<br>
Of course, Cog , even if it optimize things cleverly, still has to<br>
follow a code, and should create a real instances of Character,<br>
simply because it is written so, and it should honor the language semantics.<br>
<div><div></div><div class="h5"><br>
<br>
On 15 May 2010 01:53, Igor Stasenko <<a href="mailto:siguctua@gmail.com">siguctua@gmail.com</a>> wrote:<br>
> On 15 May 2010 01:38, Eliot Miranda <<a href="mailto:eliot.miranda@gmail.com">eliot.miranda@gmail.com</a>> wrote:<br>
>> Hi Igor,<br>
>> is the NB implementation mapping the character codes in the wide strings<br>
>> into Character objects and taking the character hashes? If so, very cool.<br>
>> The NB code is very fast. If on the other hand you're just<br>
>> short-circuiting the character code lookup then you're cheating :)<br>
>><br>
> What mapping you have in mind?<br>
><br>
> WideString>>at: index<br>
> "Answer the Character stored in the field of the receiver indexed by<br>
> the argument."<br>
> ^ Character value: (self wordAt: index).<br>
><br>
> Character class>>value: anInteger<br>
> "Answer the Character whose value is anInteger."<br>
><br>
> anInteger > 255 ifTrue: [^self basicNew setValue: anInteger].<br>
> ^ CharacterTable at: anInteger + 1.<br>
><br>
> (Character classPool at: #CharacterTable) withIndexDo: [:ch :i | self<br>
> assert: (ch asInteger = (i-1))]<br>
><br>
> So, it is 1:1 correspondence between word, stored in wide string (self<br>
> wordAt: index),<br>
> and Character value, used for hashing. So, no mapping required.<br>
><br>
><br>
> --<br>
> Best regards,<br>
> Igor Stasenko AKA sig.<br>
><br>
<br>
<br>
<br>
--<br>
Best regards,<br>
Igor Stasenko AKA sig.<br>
<br>
</div></div></blockquote></div><br></div>