November 2011 Archives

Minimizing script startup overhead

Here are some of the techniques I use to minimize startup overhead. Due to the nature of our application (command-line tools), we would like quick responses everytime a script is called from the shell.

1) Avoid Moose. Mouse used to be a bit too heavy for my taste too, so we always use Moo, but nowadays I guess Mouse is okay, especially since Mouse provides much more feature. But in general I still avoid OO-style or use bare Perl5 OO for simpler app…

Poor man's AutoLoader

For some reason that I have not bothered to investigate yet (but probably due to my screwed up perlbrew installation), AutoLoader fails to work with 'prove' and 'dzil test'. I just need to separate a couple of heavy routines off the main module, to shave startup time. So here's what I did:

1) Manually split the heavy routines to My/Module/ and My/Module/

2) In My/, add:

use vars qw($AUTOLOAD);
my ($pkg, $sub) = $AUTOLOAD =~ /(.+)::(.+)/;
die "Undefined subroutine" unl…

Module wishlist #1

This posting series relate to wishlist for existing modules. Some items are serious, some are not. I have not created a patch or submitted an RT ticket for the items, I'm posting them first to see other people's take on things.

1. Parallel cpanm. Last time I checked, there's a github issue on it. Ever had to install 200-300 modules on new servers? Without -n? Not for the terribly impatient. I suspect this is best implemented by a wrapper for cpanm.

2. DateTime->from_ymd(). It irks me that I have to write DateTime->new(year=>Y, month=>M, day=>D) everytime or (worse) having to u…

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays).