in reply to Perl slower than java
For example, for some of those smaller functions, I'd do this:
sub gene_length { my @gls = sort map { length } keys %genome; die "Invalid genotype" unless $gls[0] == $gls[$#gls]; return $gls[0]; }
And this:
use List::Util 'first'; sub check_for_winner { return first { get_result($_) == $target } @population }
And this;
use List::Util 'sum'; sub get_population_fitness_score { return sum map { get_fitness_score($_) } @population; }
(Or just inline those statements, if they're only used once.)
In other words, when you can trim it down so that you can actually tell what it's doing at a glance, then it's easier to benchmark!.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Perl slower than java
by ikegami (Patriarch) on Dec 08, 2010 at 22:57 UTC | |
by Anonymous Monk on Dec 08, 2010 at 23:03 UTC | |
by Christian888 (Acolyte) on Dec 08, 2010 at 23:05 UTC | |
by ikegami (Patriarch) on Dec 09, 2010 at 04:55 UTC | |
by anonymized user 468275 (Curate) on Dec 09, 2010 at 00:24 UTC |