You might try using a random (or at least less predictable)
set of keys, instead of just incrementing by one each time.
I don't have any evidence to back this up, but my intuition
tells me using sequential keynames isn't really a very good
test here. Seed the random number generator with the same
seed inside each code block seed to ensure you're getting
the same sequence of keys in each.
Also, if you only preallocate to 10000 buckets and you're
inserting 10000 keys, it's going to need to reallocate at
least once anyway (the largest reallocation, therefore the
slowest?). A better test might be to preallocate
20000 buckets, and then do 10000 insertions.
Does anyone know how clever perl's hashing function is?
And how does Perl deal with key hash collisions? How
feasible is it that Perl might be getting a significant
enough number of hash collisions that the number of buckets in the hash
is insignificant?
Alan
Update: Thanks for the pointer to the information about
the Perl hashing fucntion. After reading that, I can confidently
say that in Older versions of Perl, inserting sequential keys
would cause a lot of hash collisions, but with the new hashing function,
that shouldn't be a problem.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.