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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |