Perl: the Markov chain saw | |
PerlMonks |
Re: Managing multi-key hash tables....by ivancho (Hermit) |
on Apr 28, 2008 at 18:57 UTC ( [id://683348]=note: print w/replies, xml ) | Need Help?? |
Hash of hashes on 1.8 million entries might be a little heavy on the memory..
Additionally, you hit yourself for 50x the runtime, since you iterate through all the hash keys for every NetFanout in which you are interested. What you need to ask yourself here is whether the hash table is required at all.. A hash table gives you fast random access to entries - you don't use that anywhere. All you need to do is iterate through it all. Plus, your $NetFanout is a small integer number - why hash it at all? - use it to index into an array directly - this way you don't even need to explicitly sort, you get that for free. Instead of doing try Note that I use an extra technique to store things in small arrays to save on memory, but enumerate their positions to keep further code readable. Now (with some other cleanup) your summary code becomes:
In Section
Seekers of Perl Wisdom
|
|