stubby - commandline tool for dumping stub Perl programs sequentialized using Sub::Genius.
Example redirects to a file, ./spawn-combine.pl
./spawn-combine.pl
$ stubby init --run once -p "can bejust a list of subroutines" > ./spawn-combine.pl
$ stubby init --run nodeps -p "init ( subA & subB ) middle ( subA & suB ) fin" > ./spawn-combine.pl
Note: while this necessarily causes a PRE to be cached, the code generated also doesn't use Sub::Genius ();, so the caching effect on this subcommand is only as useful for making this command faster. See precache subcommand below for a more useful approach for caching.
use Sub::Genius ();
precache
precache outputs the absolute path to the cache file on completion.
$ CACHEFILE=$(stubby precache -p "init (subA & subB ) middle (subC & subD) fin") $ echo Cache file is ${CACHEFILE} $ CACHEFILE=$(stubby precache -f ./my-preplan.preplan -d put/in/here) $ echo Cache file is ${CACHEFILE}
Note: ./my-preplan.preplan should generate the same checksum (and cache) as the PRE specified using -p in the first example.
./my-preplan.preplan
-p
init (subA & subB ) middle (subC & subD) fin
Sub::Genius tries very hard to generate a consistent representation of the PREs, basically by minifying them.
Sub::Genius
General commandline tool for doing usefuly things while developing or distributing applications that use Sub::Genius.
export - dumps the minimized DFA resulting from the PRE in GraphViz's dot format. Useful with programs such as xdot, which is a viewer; in addition to the rendering programs provided by GraphViz, such as dot, circo, etc.
export
PRE
dot
xdot
circo
init - generates boilerplate Perl to help start a script, module, or project that is using Sub::Genius.
init
list - enumerates all valid strings accepted by the PRE that is provided; this is useful for verifying all of the orderings in which the PRE describes the serialized execution plan.
list
precache - provides a compiler-like tool for precaching PREs that Sub::Genius is able to use natively for skipping the potentially expensive step of convering a PRE (preplan) to a DFA (the thing FLAT uses to generate valid (i.e., sequentially consistent) execution plans.
-f|--prefile
path/to/PRE.preplan
Specify the PRE from a file. Mutually exclusive with -p|--preplan.
-p|--preplan
An the actual PRE that is to be cached. Mutually exclusive with -f|--prefile, which can be used to specify a PRE in a text file.
The init subcommand does not convert a PRE to a DFA, it simply takes a space delimited list of subroutine names, that are then used to generate minimal subroutine stubs. It is then a starting point for the developer of the code to manually edit the PRE (contained as a scalar string, $preplan) and implement the bodies of the subroutines.
$preplan
-x|--run
Choose invocation method to use in the code. The default is once.
once
Options include:
once - generates code that invokes Sub::Genius::run_once.
Sub::Genius::run_once
any - generates code that invokes Sub::Genius::run_any.
any
Sub::Genius::run_any
all - generates code that invokes Sub::Genius::run_once, in a do { ... } while () loop.
all
do { ... } while ()
nodeps - generates code that is free of any dependencies, including Sub::Genius.
nodeps
An actual PRE, when used with -x|--run [ once | any | all ], the subroutine names are stripped and used, but the PRE is not converted to a DFA.
[ once | any | all ]
when used with -x|--run nodeps, the PRE is necessarily generates subroutine calls that must necessarily be sequentially consistent.
-x|--run nodeps
Effectively compiles a PRE using Sub::Genius's caching feature. As long as PREs that produced the same checksum by Sub::Genius and the cachedir is the same, this allows one to prepare and distribute any number of pre-compiled DFAs. For sufficiently large or highly shuffled PREs, this can be leveraged to virtually eliminate the overhead associated with using Sub::Genius in deployed code..
checksum
cachedir
-d|--cachedir
path/to/cachedir
Specifies the cachedir to use for saving the cached DFAs. See Sub::Genius for more information about caching. This option is passed to the cachedir parameter of the constructor.
--force
Forces re-caching of previously cached DFAs, or at least for those matching the checksum and are located in the same cachedir.
Probably
perl5
OODLER 577 <oodler@cpan.org>
To install Sub::Genius, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Sub::Genius
CPAN shell
perl -MCPAN -e shell install Sub::Genius
For more information on module installation, please visit the detailed CPAN module installation guide.