alan,

This is a pretty good question. For timing scripts, I would recommend using Benchmark module (especially the code snippet shown in the new method). For benchmarking the importing of modules, that would be a little trickier since your probably using "use" which is a compile time directive. You could revert to loading your modules the old way ("require' and 'import') for timing.

That being said, there are two issues concerning modules versus "all-in-one" scripts (AIOS). AIOS are easier for end users to manage - especially with the disdain some hosting companies (or sysadmin teams) show in upgrading the perl lib. Modules are easier to maintain from a developer prospective. I prefer modules but some are getting pretty close to "dll hell" status and do not take advantage of the Autoloader.

In theory, modules would be slightly slower than AIOSes if every piece of code in the module is exercised. You save from a very small amount of load time for small modules to a very significant amount of time for large modules and many modules. The key here is import only the code you need. That can be accomplished by very wise module layout (and use) or by wise use of the Autoloader. You want to avoid importing code that will never be used by your script.

So my .02 cents would be to continue with what you're comfortable with especially if you have to maintain it. Also if your modules start to grow, use Autoloader to speed up your start time (and save on memory).

-derby


In reply to Re: CGI speed: one script versus many modules by derby
in thread CGI speed: one script versus many modules by alanraetz

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.