lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> So, here are some measures. One issue is: what to choose as supposedly
> representative input data? In particular, the proportion of equal strings
> (ones,
> which are actually stored in the pool, either because we mean to look them
> up or
> by chance) determines the number of petential memcmp's and thus the
> possible
> influence of checking the hash before. So, I decided to feed the pool with
> random strings of fix length=7 

So this test would show the maximum expected benefit of the hash-compare.

> [Result
> Time is CPU time (just diff in clock()).

clock() is not the right tool in this case.

> Conclusion: in absence of more
> info (such as the reason why it's there in Lua), let it down.

Me impression too.

> However, I initially placed the hash in the string struct (as is done in Lua, a
> point I stepped on by chance and was the reason for my question) for
> another
> reason: i keep the hash anyway to avoid re-hashing when the pool grows, so
> why
> not put it in the string instead of on the cell struct (node)? If ever useful,
> it's there, while someone having access to the string but not to the cell would
> just not have it...

If I am not mistaken string-data and hash-node occupy the same memory block in Lua.

   Jörg