Pardon my noob-ness. Let me add some more details and try to answer some questions. The code is running as a mod_perl app so I would think all of this code would be loaded when the server is started up. I do need all of them loaded since I dont know when they might be used. Unfortunately use of use parent isnt that easy in my ecosystem. We have development environments on 5.8 still and other environments on 5.20.2. That wrinkle aside, I am stuck with this hardware and configuration, I need to make due with what I am given.
So the unsplit file looks a little more like this.
package ThisIsMyPackge;
package Foo;
package A
our @ISA = qw{Foo};
sub validate {
do something;
}
package B
our @ISA = qw{Foo};
sub validate {
do something;
}
package C
our @ISA = qw{Foo};
sub validate {
do something;
}
package Bar;
package D
our @ISA = qw{Bar}
sub apply {
do something;
}
package E
our @ISA = qw{Bar}
sub apply {
do something;
}
package F
our @ISA = qw{Bar}
sub apply {
do something;
}
And the split version now looks like this:
package ThisIsMyPackge;
use A;
use B;
use C;
use D;
use E;
use F;
use 79 more times ...
.....
I didnt use Benchmark, I used Time::HiRes to calculate the time it takes to run the foreach loop (modified) below. The timings are based on average of 5 runs through the code. I have done more runs but the results dont differ so I use 5 for my calculations. Note this foreach loop isnt called in ThisIsMyPackge.pm, its called from another file.
unsplit: .14858s
split: .4153s
foreach my $bar (@{$objects}) {
my $foo = $bar->object;
....
next unless $foo->validate;
$bar->apply;
....
}
I put it in other timings to isolate the bottleneck and the slow down is around the $foo->validate and $bar->apply calls. All of the other logic in the loop has its timings almost exactly the same. The results from Devel::NYTProf also point to this area of the code as well. This might not seem like a lot of time but over the course of thousands of concurrent hits, it is a pretty big decrease in performance.
|