To optimise you need to identify where the time is spent. The most useful tool is Devel::DProf which will detail the percentage of time spent in each section of your code. You are wasting your time doubling the speed of a part of code that only takes up 1% of the total runtime. On the other hand a small improvement in bottleneck areas will reap large benefits. Assuming you have a 'normal' database driven website consider:

  1. Profiling with tools, see Devel::Dprof is your friend
  2. Optimising bottlenecks with Benchmark et al
  3. use mod_perl and Apache::Registry or for vanilla CGI CGI::Simple or CGI.pm in order of speed to process your params.
  4. Generate a cache of static documents for slow changing content rather than serving all requests from a database
  5. Connect to your database once (slow) and use prepare_cached($sql) with ? placeholders in the SQL and then execute(@values)
  6. Think about how much your time is worth versus the cost of new faster equipment or more ram or more processors or faster disks or a better load balancer or....

Often perlcode per say is not the bottleneck. You can't effectively optimise unless you identify where it is worth investing the effort.

cheers

tachyon

s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print


In reply to Re: Does anyone have a list of 'donts' when optimizing? by tachyon
in thread Does anyone have a list of 'donts' when optimizing? by BUU

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.