[squeak-dev] WideString hash is way slower than ByteString hash.
Igor Stasenko
siguctua at gmail.com
Fri May 14 22:14:55 UTC 2010
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.
More information about the Squeak-dev
mailing list
|