Slashdot Mirror


Optimizing Perl

An anonymous reader writes "Perl is an incredibly flexible language, but its ease of use can lead to some sloppy and lazy programming habits. We're all guilty of them, but there are some quick steps you can take to improve the performance of your Perl applications. This article looks at the key areas of optimization, which solutions work and which don't, and how to continue to build and extend your applications with optimization and speed in mind."

8 of 68 comments (clear)

  1. Re:Here's My Style Guide by hattmoward · · Score: 3, Interesting

    I usually put the CVS $Log: $ at the end of the script, after an __END__, and place a note about it at the top. You can also use the following snippet if you want to make your module's version equivalent to the CVS revision number: use vars qw($VERSION); $VERSION = ('$Revision: $ ' =~ /(\d+\.\d+)/)[0];

  2. Re:Here's My Style Guide by Anonymous Coward · · Score: 2, Interesting

    Oops! I'm so used to <code> tags at Perl Monks...

    use vars qw($VERSION);
    $VERSION = ('$Revision: $ ' =~ /(\d+\.\d+)/)[0];

  3. And then stress-test with Slashdot ... by xmas2003 · · Score: 4, Interesting
    I use Perl for my halloween webcam - same code is used in the christmas webcam ... and thought I had it in pretty decent shape ... until the Slashdot thundering herd descended on it and gave it one heck of a stress test.

    For instance, flock is your friend ... and as I outline in my slashdot effect analysis you had better be prepared to handle race conditions. Ignoring the web server overload (mod_perl would have helped here), the code actually hung in there fairly well as I've learned from past "mistakes" when I've seen some pretty funky error messages crop up ... but even this time around, there was two minor corner cases I failed to account for (had never been "tickled" before) ... but those are fixed now so I'll be "more" ready if my christmas lights show up on Slashdot again ... but then again, you are never really "ready" for Slashdot! ;-)

    --
    Hulk SMASH Celiac Disease
  4. Article is seriously flawed by Anonymous Coward · · Score: 2, Interesting

    I'm still working through it, but I cannot reproduce its purported effects.

    First it has a syntactical error with the "x" operator; it puts the number on the left and the string on the right, but the actual syntax it the other way around. If the author had actually tried to run his examples, he would have noticed this.

    Then the author says that putting as much text in a single-quoted string as possible better, and says that something like:
    print 'aaaaaaaaaaaaaaaaaa',"\n" ;
    is better than:
    print "aaaaaaaaaaaaaaaaaa\n";

    I just tested this, and not only could I find no difference between single and double-quoted strings with the same amount of text, the suggested "improvement" with two separate strings, above, was significantly SLOWER than the second version.

    At this point I lost interest (and respect) and stopped checking. but don't take my word for it, try it youself! Are you getting different results?

  5. Optimizing schmoptimizing by cryptor3 · · Score: 3, Interesting

    I have a friend who works at a big company that provides a lot of "utility" to its customers.

    They run perl scripts all the time to crunch text files containing lots of data coming in from remote sensors and stuff like that. He told me that the more senior guys have the philosophy is "Optimize? nah, just let it run the extra 20 minutes."

    And they're talking about scripts that get run in a cron job DAILY.

  6. Re:Optimization Rules! by Anonymous Coward · · Score: 1, Interesting

    Unfortunately, perl is now used in bioinformatics an awful lot. Genetic analyses are (rather frighteningly) regularly carried out in perl. While any computer scientist would point out that lisp or, hell, even python, would be more appropriate, yes, that 3 second difference probably does matter to some people.

  7. parse tree by Doc+Ruby · · Score: 2, Interesting

    Perl compiles its code into an intermediary "tree" of logic nodes (Perl "opcodes"). Are there any topology strategies for optimizing that tree, in the graph itself? Any visualization tools that let Perl generate the tree, then let a programmer change the tree, then complete the compilation of the new tree to new code? Is Parrot/Perl6 making any of these strategies more feasible, or are they all going away?

    --

    --
    make install -not war

  8. My 0.02 Euro ;) by kompiluj · · Score: 3, Interesting

    Well for me the greatest optimization is Perl itself, which allows to quickly write potent code. It spares the programmer's time, which costs much more than machine time. And as to optimization - well I think that a good optimizing compiler should do the job - you know I couldn't recognize my inefficient C++ code after running it through the Intel C++ compiler - it has improved soooo much!

    --
    You can defy gravity... for a short time