For one, you are doing a lot less dereferencing. To set the properties on each chromosome in the non-OOP version you do a double dereference: $new_population->[$individual]->{propname}. There are four properties (chromosome, result, phenotype, fitness_score). This amounts to 4 * the number of chromosomes dereferences, or for a sample with 100 chromosomes, 400 double dereferences per regeneration. In the OOP version you build the chromosome and then push it on the array, resulting in a single dereference, i.e. 400 single dereferences. Although dereferences are cheap if you are doing millions of them as a result of several thousand regenerations, they do add up.
In reply to Re: Procedural Perl slower than OO Perl!!!
by ELISHEVA
in thread Procedural Perl slower than OO Perl!!!
by Christian888
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |