<br><br><div class="gmail_quote">On Fri, May 14, 2010 at 10:28 AM, Levente Uzonyi <span dir="ltr">&lt;<a href="mailto:leves@elte.hu">leves@elte.hu</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Fri, 14 May 2010, <a href="mailto:christophe.jalady@free.fr" target="_blank">christophe.jalady@free.fr</a> wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Just print this two scripts:<br>
<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000 timesRepeat: [s hash]] timeToRun.<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000 timesRepeat: [s hash]] timeToRun.<br>
<br>
I&#39;ve seen that &quot;ByteString&gt;&gt;stringHash:initialHash&quot; use a primitive. Could we<br>
have such optimisation for WideString ?<br>
</blockquote>
<br></div></div>
Sure. There are (at least) four ways to do it:<br>
1) Update the implementation of the primitive to support wordarrays. Then build a vm with it and finally change the image side code. This would be the best IMHO. Is there a reason why the primitive is not implemented this way?<br>

2) Use NativeBoost to write a primitive for this method. This is much easier than building a vm/plugin, though you have to write the code in X86 assembly. This would be a cool demo for NativeBoost&#39;s primitive writing capabilities. (Much better than the Fibonacci-number calculator. :))<br>

3) Use Exupery, I think it can optimize methods like this.<br>
4) Use the Cog VM. ;) (I wonder how fast this method is with Cog.)<br></blockquote><div><br></div><div>2.66GHz Intel Core i7 MacBook Pro (my new tool!!!!).  Current Cog, my 3.8 derived work image:</div><div><br></div><div>
|s|</div><div>s := WideString with: (Character value: 16r55E4).</div><div>[100000 timesRepeat: [s hash]] timeToRun. 16</div><div><br></div><div>|s|</div><div>s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)</div>
<div>with: (Character value: 16rE4) with: (Character value: 16rE4).</div><div>[100000 timesRepeat: [s hash]] timeToRun. 10</div><div><br></div><div>|s|</div><div>s := WideString with: (Character value: 16r55E4).</div><div>
[100000000 timesRepeat: [s hash]] timeToRun. 15725</div><div><br></div><div>|s|</div><div>s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)</div><div>with: (Character value: 16rE4) with: (Character value: 16rE4).</div>
<div>[100000000 timesRepeat: [s hash]] timeToRun. 11078</div><div><br></div><div><br></div><div>Current 4.1/Squeak 4.1.1beta2U.app:</div><div><div>|s|</div><div>s := WideString with: (Character value: 16r55E4).</div><div>
[100000 timesRepeat: [s hash]] timeToRun. 98</div><div><br></div><div>|s|</div><div>s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)</div><div>with: (Character value: 16rE4) with: (Character value: 16rE4).</div>
<div>[100000 timesRepeat: [s hash]] timeToRun. 31</div><div><br></div><div>|s|</div><div>s := WideString with: (Character value: 16r55E4).</div><div>[100000000 timesRepeat: [s hash]] timeToRun. 100660</div><div><br></div>
<div>|s|</div><div>s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)</div><div>with: (Character value: 16rE4) with: (Character value: 16rE4).</div><div>[100000000 timesRepeat: [s hash]] timeToRun. 29476</div>
<div><br></div><div>Current 4.1/current Cog</div></div><div><div>|s|</div><div>s := WideString with: (Character value: 16r55E4).</div><div>[100000 timesRepeat: [s hash]] timeToRun. 14</div><div><br></div><div>|s|</div><div>
s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)</div><div>with: (Character value: 16rE4) with: (Character value: 16rE4).</div><div>[100000 timesRepeat: [s hash]] timeToRun. 10</div><div><br></div>
<div>|s|</div><div>s := WideString with: (Character value: 16r55E4).</div><div>[100000000 timesRepeat: [s hash]] timeToRun. 14946</div><div><br></div><div>|s|</div><div>s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)</div>
<div>with: (Character value: 16rE4) with: (Character value: 16rE4).</div><div>[100000000 timesRepeat: [s hash]] timeToRun. 10171</div><div><br></div><div>So quite a bit faster :)</div><div><br></div><div>best</div><div>Eliot</div>
<div><br></div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<br>
<br>
Levente<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Christophe.<br>
<br>
<br>
</blockquote>
<br>
</blockquote></div><br>