On Sat, 15 May 2010, christophe.jalady@free.fr wrote:
Should the hash function be the same between ByteString and WideString ? I mean: if a WideString contains the same characters than a ByteString, I guess that they should have both the same hashcode no ?
Yes, they should be the same. And they are the same, aren't they?
Levente
Christophe
----- Mail Original ----- De: "Igor Stasenko" siguctua@gmail.com ˙˙: "The general-purpose Squeak developers list" squeak-dev@lists.squeakfoundation.org Envoyé: Samedi 15 Mai 2010 00h26:18 GMT +01:00 Amsterdam / Berlin / Berne / Rome / Stockholm / Vienne Objet: Re: [squeak-dev] WideString hash is way slower than ByteString hash.
added implementation into examples package: http://www.squeaksource.com/NativeBoost/NativeBoost-Examples-Igor.Stasenko.1...
On 15 May 2010 01:14, Igor Stasenko siguctua@gmail.com wrote:
I implemented WideString hash in NB.
|s| s := WideString with: (Character value: 16r55E4). [100000000 timesRepeat: [s hash]] timeToRun. 155718
|s| s := WideString with: (Character value: 16r55E4). [100000000 timesRepeat: [s nbHash]] timeToRun. 81231
Which makes me think, that we're benching the outer loop, rather then hash function itself :)
So, here is more appropriate , i think:
|s t1 t2 | s := (WideString with: (Character value: 16r55E4)) , 'abcdefghijklmno'. 10 timesRepeat: [ s := s , s ]. self assert: (s hash = s nbHash). t1 := [1000 timesRepeat: [s hash]] timeToRun. t2 := [1000 timesRepeat: [s nbHash]] timeToRun.
{ t1. t2 } #(11479 134)
~ 85x faster :)
-- Best regards, Igor Stasenko AKA sig.
-- Best regards, Igor Stasenko AKA sig.