[squeak-dev] WideString hash is way slower than ByteString hash.

Levente Uzonyi leves at elte.hu
Fri May 14 17:28:31 UTC 2010


On Fri, 14 May 2010, christophe.jalady at free.fr wrote:

> Just print this two scripts:
>
> |s|
> s := WideString with: (Character value: 16r55E4).
> [100000 timesRepeat: [s hash]] timeToRun.
>
> |s|
> s := ByteString with: (Character value: 16rE4) with: (Character value: 16rE4)
> with: (Character value: 16rE4) with: (Character value: 16rE4).
> [100000 timesRepeat: [s hash]] timeToRun.
>
> I've seen that "ByteString>>stringHash:initialHash" use a primitive. Could we
> have such optimisation for WideString ?

Sure. There are (at least) four ways to do it:
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?
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's primitive writing 
capabilities. (Much better than the Fibonacci-number calculator. :))
3) Use Exupery, I think it can optimize methods like this.
4) Use the Cog VM. ;) (I wonder how fast this method is with Cog.)


Levente

>
> Christophe.
>
>



More information about the Squeak-dev mailing list