<br><br><div class="gmail_quote">On Fri, May 14, 2010 at 1:03 PM, 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, Eliot Miranda wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, May 14, 2010 at 10:28 AM, Levente Uzonyi &lt;<a href="mailto:leves@elte.hu" target="_blank">leves@elte.hu</a>&gt; wrote:<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
On Fri, 14 May 2010, <a href="mailto:christophe.jalady@free.fr" target="_blank">christophe.jalady@free.fr</a> wrote:<br>
<br>
 Just print this two scripts:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<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:<br>
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<br>
we<br>
have such optimisation for WideString ?<br>
<br>
</blockquote>
<br>
Sure. There are (at least) four ways to do it:<br>
1) Update the implementation of the primitive to support wordarrays. Then<br>
build a vm with it and finally change the image side code. This would be the<br>
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<br>
easier than building a vm/plugin, though you have to write the code in X86<br>
assembly. This would be a cool demo for NativeBoost&#39;s primitive writing<br>
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>
<br>
</blockquote>
<br>
2.66GHz Intel Core i7 MacBook Pro (my new tool!!!!).  Current Cog, my 3.8<br>
derived work image:<br>
<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000 timesRepeat: [s hash]] timeToRun. 16<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value:<br>
16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000 timesRepeat: [s hash]] timeToRun. 10<br>
<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000000 timesRepeat: [s hash]] timeToRun. 15725<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value:<br>
16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000000 timesRepeat: [s hash]] timeToRun. 11078<br>
<br>
<br>
Current 4.1/Squeak 4.1.1beta2U.app:<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000 timesRepeat: [s hash]] timeToRun. 98<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value:<br>
16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000 timesRepeat: [s hash]] timeToRun. 31<br>
<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000000 timesRepeat: [s hash]] timeToRun. 100660<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value:<br>
16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000000 timesRepeat: [s hash]] timeToRun. 29476<br>
<br>
Current 4.1/current Cog<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000 timesRepeat: [s hash]] timeToRun. 14<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value:<br>
16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000 timesRepeat: [s hash]] timeToRun. 10<br>
<br>
|s|<br>
s := WideString with: (Character value: 16r55E4).<br>
[100000000 timesRepeat: [s hash]] timeToRun. 14946<br>
<br>
|s|<br>
s := ByteString with: (Character value: 16rE4) with: (Character value:<br>
16rE4)<br>
with: (Character value: 16rE4) with: (Character value: 16rE4).<br>
[100000000 timesRepeat: [s hash]] timeToRun. 10171<br>
<br>
So quite a bit faster :)<br>
</blockquote>
<br></div></div>
Thanks, it looks really nice. I wonder why are the results with 4.1 better than with your 3.8 derived image.<br></blockquote><div><br></div><div>The code looks the same and so I expect the times are close enough to be in the noise.  I didn&#39;t shut my machine down to a consistent state so other tasks could have affected things, etc.</div>
<div><br></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>
best<br>
Eliot<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Levente<br>
<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Christophe.<br>
<br>
<br>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote>
<br>
</blockquote></div><br>