Part of your slowdown may come from the repeated reallocation of the base data structure for the hash. There's an array in there that holds the elements of the hash--when it's full, perl has to allocate a new, larger chunk and copy the data from the old chunk to the new one. (This also tends to frag memory) You can use keys in an lvalue context (
keys %foo = 1000000) to presize the hash, which may help some.
Depending on how well your keys hash out, you may find you're badly overloading one of the buckets in the hash structure as well. While perl tries to make sure the keys are evenly distributed by the hashing function, it doesn't always succeed, and in that case there's not a whole lot you can do. Printing the hash in scalar context will give you a little bit of info about that--if you see the two numbers returned are wildly different, you've got a badly mis-balanced hash. (In which case you're kinda out of luck)
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.