Welcome to the Monastery | |
PerlMonks |
Re: Why is my program so slow even though I've used hashes?by moritz (Cardinal) |
on May 28, 2009 at 16:30 UTC ( [id://766693]=note: print w/replies, xml ) | Need Help?? |
Well, programs don't run faster magically just because you use hashes. They only give you speed if you don't have to loop over the whole hash, but look up the values by key.
So instead of using your current keys for storage, use the value that is called $pdbchain in your program as a hash key. Then you can replace whole while (($key, $value) = each %hash) { if ($a eq $b) { ... } } with a single hash lookup, which should improve the performance.
In Section
Seekers of Perl Wisdom
|
|