You got it just right. Added more comparisons testing casting and unrolled the hash.
See https://gist.github.com/2842215 0.00047ms per key for tableU32, return hash >>> 0 0.00005ms per key for tableU31, return hash >>> 0 0.00004ms per key for tableS32, return hash 0.00025ms per key for tableS32, return hash >>> 0 0.00005ms per key for tableS32, return hash < 0 ? 4294967296 + hash : hash On Wednesday, May 30, 2012 7:41:09 PM UTC+2, Vyacheslav Egorov wrote: > > So I threw in some code: https://gist.github.com/2837822 That does > something similiar to what you described (but not necessarily > completely similiar): it just does some int32 bitwise operations. > > On my machine x64.release build of V8 takes 8ms (0.00008 ms per key). > > If I start casting result to uint32 via >>> 0, I get to 36ms > (0.00036ms per key). > > Limiting number of bits inside the table does not improve anything > (which is quite expected with code shaped like that). > > -- > Vyacheslav Egorov > > On Wed, May 30, 2012 at 7:10 PM, Joran Greef <jo...@ronomon.com> wrote: > > Keeping everything as Int32 but casting using "return hash >>> 0" > > is 0.00022ms per key. > > > > Keeping everything as Int32 but casting using "return hash < 0 ? > 4294967296 > > + hash : hash" is 0.000051ms per key, order of magnitude faster and > still > > 32-bit. > > > > > > On Wednesday, May 30, 2012 6:25:39 PM UTC+2, Vyacheslav Egorov wrote: > >> > >> c) stop doing >>> 0 at the end; > > > > -- > > v8-users mailing list > > v8-users@googlegroups.com > > http://groups.google.com/group/v8-users > -- v8-users mailing list v8-users@googlegroups.com http://groups.google.com/group/v8-users