Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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.

The start of some sanity?


In reply to Re: Multiprocessing on Windows (Cannot reproduce!) by BrowserUk
in thread Multiprocessing on Windows by JohnRS

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (3)
As of 2024-04-20 01:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found