in reply to Multiprocessing on Windows
In summary, my questions are:
Are you running Windows in a VM? That's the only thing that comes to mind that might explain your results. I cannot reproduce them at all
I only have 4 cores, and the result from your script (slightly tweaked) show an almost perfect split of processing:
#! perl -slw use strict; use threads; use Time::HiRes 'time'; our $T //= 4; my @threads; my $start = time; foreach my $i (1 .. $T ) { $threads[$i] = threads->create(\&Work, $i); } foreach my $i ( 1 .. $T ) { $threads[$i]->join(); } my $stop = time - $start; printf "\nclock: %f sec user: %f\n", $stop, (times())[0]; exit; ##### sub Work { my ($i) = @_; foreach ( 1 .. ( 20e5 / $T ) ) { my $acct_nrs = "abc\txyz\tdef\tabc\tghi\tghi"; my @temp = split(m/\t/, $acct_nrs, -1); @temp = ( sort keys %{{ map { $_ => 1 } @temp }} ); my $ans = join(', ', @temp); } printf " $i"; return; } __END__ C:\test>for /l %i in (1,1,4) do @972137 -T=%i 1 clock: 29.351637 sec user: 29.093000 1 2 clock: 14.986346 sec user: 29.765000 1 2 3 clock: 10.131188 sec user: 29.968000 2 3 4 1 clock: 7.781729 sec user: 29.796000
Update: Ditto for 5.14:
C:\test>for /l %i in (1,1,4) do @\perl64-14\bin\perl.exe -slw 972137.p +l -T=%i 1 clock: 27.309776 sec user: 27.343000 2 1 clock: 13.878018 sec user: 27.625000 2 1 3 clock: 9.370494 sec user: 27.875000 3 2 1 4 clock: 7.205594 sec user: 27.765000
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Multiprocessing on Windows (Cannot reproduce!)
by JohnRS (Scribe) on May 24, 2012 at 02:21 UTC | |
by JohnRS (Scribe) on May 24, 2012 at 06:30 UTC | |
by BrowserUk (Patriarch) on May 24, 2012 at 18:06 UTC | |
by BrowserUk (Patriarch) on May 25, 2012 at 03:34 UTC | |
by JohnRS (Scribe) on May 25, 2012 at 11:20 UTC |
In Section
Seekers of Perl Wisdom