Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

To display the location, I changed the code accordingly and run 1 time. Running serially seems fast enough. Basically, Perl completes in less than 1 second for 1 million keys from an Intel i7 Haswell chip running at 2.6 GHz. Nethertheless, this post was written to demonstrate workers sending data to the manager-process for STDOUT via MCE->print(...).

Results: run 1 and 2 times for 1 million keys: $max set to 1e6.

$ perl demo2.pl haukex 1 Found at 999999 Found at 1000000 duration (haukex): 0.336 seconds $ perl demo2.pl karlary 1 Found at 999999 Found at 1000000 duration (karlary): 0.231 seconds $ perl demo2.pl karlseq 1 Found at 999999 Found at 1000000 duration (karlseq): 0.122 seconds
$ perl demo2.pl haukex 2 Found at 999999 Found at 1000000 Found at 999999 Found at 1000000 duration (haukex): 0.665 seconds $ perl demo2.pl karlary 2 Found at 999999 Found at 1000000 Found at 999999 Found at 1000000 duration (karlary): 0.477 seconds $ perl demo2.pl karlseq 2 Found at 999999 Found at 1000000 Found at 999999 Found at 1000000 duration (karlseq): 0.253 seconds

Below, workers report the location.

... { no strict 'refs'; my $start = time; $func->() for 1 .. $count; printf "duration ($func): %0.03f seconds\n", time - $start; } ... sub haukex { # serial code for my $key ( 1 .. $max ) { print "Found at $key\n" if ( $barcode_hash{$key}[2] eq $barcode_pair_35 ); } return; } sub karlary { # workers receive next array chunk mce_loop { my ( $mce, $chunk_ref, $chunk_id ) = @_; for my $key ( @$chunk_ref ) { MCE->print("Found at $key\n") if ( $barcode_hash{$key}[2] eq $barcode_pair_35 ); } } 1 .. $max; # <-- for array 1 .. $max return; } sub karlseq { # workers receive next sequence 'begin' and 'end' boundaries mce_loop_s { my ( $mce, $chunk_ref, $chunk_id ) = @_; for my $key ( $chunk_ref->[0] .. $chunk_ref->[1] ) { MCE->print("Found at $key\n") if ( $barcode_hash{$key}[2] eq $barcode_pair_35 ); } } 1, $max; # <-- for sequence 1, $max return; }

In reply to Re^3: search for particular elements of hash with multiple values by marioroy
in thread search for particular elements of hash with multiple values by pmpmmpmp

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 drinking their drinks and smoking their pipes about the Monastery: (4)
As of 2024-04-19 04:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found