[Edinburgh-pm] Code cleanup

Miles Gould miles at assyrian.org.uk
Mon Mar 5 07:53:41 PST 2012


Hey all,

Some poor fool recently posted some code to the Reddit Perl forum, 
asking for advice on improving the code's performance. The advice fell 
into five rough camps:

1) throw $random_microoptimisation at it, that's bound to help
2) use $perl_idiom instead of $c_idiom, it's much prettier
3) use SQL/BDB/R instead of Perl and flat text files (a special, and 
especially annoying, case of 1)
4) delete the whole thing, go to your room, and Think About What You've Done
5) run Devel::NYTProf on it, then you'll see that the problem is 
$actual_problem.

[You can read the whole debacle at 
http://www.reddit.com/r/perl/comments/qf9do/why_is_this_perl_code_painfully_slow/]

This was all very frustrating to those of us in camp 5. But the camp 2 
folks had a point: it was pretty clear that the programmer in question 
was new to Perl and probably fairly new to programming in general. So I 
thought I'd do a step-by-step cleanup of their code, so that they, and 
hopefully any interested bystanders, might learn.

Here's what I've got so far:

https://github.com/pozorvlak/microarray

Does anyone have any suggestions? I haven't merged the stats_basic 
branch yet because it changes the output data extensively, and I'd like 
to run a few calculations by hand to determine which set of answers is 
right.

Miles


More information about the Edinburgh-pm mailing list