in reply to Does anyone have a list of 'donts' when optimizing?

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

  • Comment on Re: Does anyone have a list of 'donts' when optimizing?