Update: The disparity is coming from strftime.
Update: One must use threads on the Mac and non-threads on Linux for best performance. This is mind-boggling to me. Replacing the strftime line with $A = $Y completes in a couple seconds for threads or non-threads on the Mac and Linux.
The same 500 MB input file is used by both OS.
Mac OS X Serial: 18.185s
Mac OS X Parallel: 6.687s threads
Mac OS X Parallel: 42.526s non-threads
CentOS 7 VM Serial: 10.832s
CentOS 7 VM Parallel: 23.849s threads
CentOS 7 VM Parallel: 2.993s non-threads
use threads; # Comment out threads for child processes
use POSIX qw(strftime);
my $mutex :shared = 0;
my $infile = $ARGV;
my $outfile = $ARGV;
open(DATAOUT, ">", $outfile);
## Workers process chunks in parallel until completed.
## Output order is preserved via MCE::Candy::out_iter_fh
chunk_size => "2m", max_workers => 4, use_slurpio => 1,
gather => MCE::Candy::out_iter_fh(\*DATAOUT)
my ($mce, $chunkRef, $chunkID) = @_;
my ($output, @Fields, $X, $Y, $A, $B, $C, $D, @G) = ("");
open my $CHUNKIN, "<", $chunkRef;
while( my $line = <$CHUNKIN> )
@Fields = split(',', $line, 9);
$X = $Fields;
$Y = substr $X, 0, 10;
@G = gmtime $Y;
$A = strftime "%M,%Y,%m,%d,%H,%j,%W,%u,%A", @G;
$B = substr($A, 0, index($A, ','));
$C = int($B/5);
$D = int($B/15);
$output .= $line.",$Y,$A,$C,$D\n";
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:
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.
| & || & |
| < || < |
| > || > |
| [ || [ |
| ] || ] |