Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
I definitely think benchmarking is the key answer here.

I think no matter what, this is an implementation specific problem. I always wrote Perl for
programmer speed, and paid less attention to execution speed. Until I started working on problems
that were big enough to deal with datasets ranging from hundreds of meg to a few gig in size.

I love Perl but for data this big, and the bit of processing required, I would have initially went
with either C or C++. BUT - I work in a place where most everyone knows Perl and not many know C/C++
so Perl optimization has become a big issue.

I've learned a lot about how slight code changes can increase efficiency, especially when
certain tasks need to be done many times over. I've seen major speed increases
just by benchmarking and trying a different solution, but keeping the same algorithm.
Things especially like
my @a = (); if ( $foo =~ /^(\d+)\s+(\w+)\s*$/ ) { @a = ($1, $2); }
vs.
my @a = split (/\s+/, $foo);


Guess what? In my system, option #1 runs about 90% faster.


-felonious --

In reply to Re: Optimizing existing Perl code (in practise) by feloniousMonk
in thread Optimizing existing Perl code (in practise) by JaWi

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-20 01:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found