Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: Parallel-processing the code

by ikegami (Pope)
on May 17, 2018 at 00:52 UTC ( #1214702=note: print w/replies, xml ) Need Help??


in reply to Parallel-processing the code

As previously mentioned, multi-tasking won't help. This prorgram is I/O-bound, and merging the results of the threads would be as expensive as building the results in the first place.

I just wanted to provide a cleaned up version of your code (with a few micro-optimizations).

#!/usr/bin/perl use strict; use warnings; use feature qw( say ); use Sort::Naturally qw( nsort ); local $/ = ''; # Paragraph mode reads until a blank line. my %grouped; while (<>) { my @lines = split /\n/, $_; for (@lines[1..$#lines]) { next if $_ eq '--'; # Omit if rarely true. ++$grouped{"D$1"}{$2} while /\bD\*([^*]*)\*([^*]*)\*D\b/g; } } for my $k (nsort keys %grouped) { say "$k=>" . join("|", keys(%{ $grouped{$k} }); }

Replies are listed 'Best First'.
Re^2: Parallel-processing the code
by rajaman (Acolyte) on May 19, 2018 at 04:12 UTC
    Thank you Ikegami. New thing learned there.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1214702]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (3)
As of 2020-11-26 19:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?