G'day almr,

I made verbatim copies of your four scripts and ran them using time (I don't have hyperfine). I performed multiple runs on each; I got results that were of the same order of magnitude as yours. So, there's nothing problematic with your system in this regard.

I see some workarounds have been suggested. I use the three modules you tested in most of my $work scripts; I've never had any comments about slowness. I don't imagine any of your users will complain that a script took 100ms to start running. :-)

You'll no doubt be loading additional modules which will increase the startup time. Keep an eye on what you're importing.

# Import nothing -- fastest but requires additional coding use Some::Module (); ... Some::Module::some_function(); Some::Module::other_function(); # Import just the parts you intend to use -- still fast; less coding use Some::Module qw{some_function other_function}; ... some_function(); other_function(); # Import everything -- could be very slow use Some::Module; ... any_function();

If you're really concerned about startup speeds, put something like this at the start of your script:

BEGIN { print "Loading app (could take a second or two) ...\n"; }

Then, when it only takes 100ms or so, your users should be very pleased.

— Ken


In reply to Re: slow startup for some common modules? (autodie, Pod::Usage, Getopt::Long)) by kcott
in thread slow startup for some common modules? (autodie, Pod::Usage, Getopt::Long)) by almr

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.