|
|
| There's more than one way to do things | |
| PerlMonks |
Re: Why does Perl get slower when building a larger hash? (Not due to the memory swapping)by kcott (Parson) |
| on Mar 01, 2013 at 02:37 UTC ( #1021141=note: print w/ replies, xml ) | Need Help?? |
|
G'day chialingh, Welcome to the monastery. The first thing I'd suggest doing is adding use warnings; (warnings) after use strict; and fix up problems that are reported. There may be others, but a couple that grabbed my attention were close IN; (a filehandle that is never opened) and my %hash1; ... my %hash1 ... (declared twice in same scope - ditto for %hash2). One place where I believe you're doing unnecessary processing is:
Rather than performing all those hash dereferences, I believe you could simply write something like:
You'd need to handle other references to %hash1 and %hash2 in a similar fashion. At the very least, I don't believe you need to create the intermediate hash %file_genes: you could just create %hash1 and %hash2 directly, like this:
If that doesn't help, you'll need to profile your code. Devel::NYTProf may be a good place to start; other modules listed under CPAN - Development Support might be useful. -- Ken
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||