[squeak-dev] WideString hash is way slower than ByteString hash.
Igor Stasenko
siguctua at gmail.com
Fri May 14 23:43:33 UTC 2010
On 15 May 2010 02:35, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> The cardinal rule of running benchmarks is to compare apples to apples.
> You've compared apples to oranges, i.e. an optimized reimplementation of
> WideString>>hash that eliminates the mapping of codes to characters, against
> the vanilla Squeak implementation. You need to at least compare the NB
> implementation against
> WideString methods for comparison
> fastHash
> | stringSize hash low |
> stringSize := self size.
> hash := ByteString identityHash bitAnd: 16rFFFFFFF.
> 1 to: stringSize do: [:pos |
> hash := hash + (self wordAt: pos).
> "Begin hashMultiply"
> low := hash bitAnd: 16383.
> hash := (16r260D * low + ((16r260D * (hash bitShift: -14) + (16r0065 * low)
> bitAnd: 16383) * 16384)) bitAnd: 16r0FFFFFFF.
> ].
> ^ hash
> | s n |
> s := (WideString with: (Character value: 16r55E4)) , 'abcdefghijklmno'.
> n := 100000.
> { [1 to: n do: [:i| s fastHash. s fastHash. s fastHash. s fastHash. s
> fastHash. s fastHash. s fastHash. s fastHash. s fastHash. s fastHash]]
> timeToRun.
> [1 to: n do: [:i| s hash. s hash. s hash. s hash. s hash. s hash. s hash. s
> hash. s hash. s hash]] timeToRun. }
> #(829 1254)
> ASo your measurements tell us nothing about a general comparison of NB
> against the Squeak VM or Cog. They only demonstrate (unsurprisingly) that a
> loop summing integers in an array goes PDQ. On the other hand my numbers
> showed Cog 10x faster than the Squeak interpreter when executing exactly the
> same bytecode.
Yes, of course you're right.
But i didn't compared it with Cog, because i can't.
And NB is not for translating bytecodes into native code,
it is for authoring a primitives using native code.
So, my comparison is how faster it could be , if implemented primitively.
I can only imagine, how faster the whole thing would be if we
cross-hatch NB and Cog,
where Cog will serve as a smalltalk optimizer , and NB will serve for
manual optimizations
for heavy numerical crunching :)
> best
> Eliot
>
--
Best regards,
Igor Stasenko AKA sig.
More information about the Squeak-dev
mailing list
|