In your FIDDLE and your SUB-REF code you seem to be
building your call list dynamically. This is a waste.
You assume you are cpu bound. You're right. But
you are bound to be, cause you are waiting to read
everything, bound to process it all, then waiting to
write it. You may be solving the wrong problem.
It is not clear whether you have enough memory to
avoid swapping. It is unknown whether you have
other tasks running in your environment. Also unknown
is whether you have multiprocessors.
Some ideas:
-
Do items one by one.
-
Do items in batches small enough to fit memory.
-
Additionally have multiple programs doing this job, 1 to 3
more processes than cpus, to start.
-
Eliminate routine calls, i.e. apple_wash_core_pulp.
-
Use a hash to look up your processes:
# off-hand untried code
PROGRAM_INIT:
my %proc_table = (
type => \&process,
apple => \&apple_wash_core_pulp,
banana => \&banana_bend_hang,
);
foreach ( @item){
&$proc_table{$type} if exists $proc_table{$type};
next;
unknown_type();
}
-
Use an array and constants instead of a hash. Similar
to the above but use &$proc_array[$type].
Also your data could loaded into an array of arrays.
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.