Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

Re: Reduce CPU utilization time in reading file using perl

by Laurent_R (Canon)
on Sep 30, 2013 at 11:40 UTC ( #1056337=note: print w/replies, xml ) Need Help??

in reply to Reduce CPU utilization time in reading file using perl

If your file are sorted in accordance with the comparison key, then you can iterate through the two files in parallel. This can be very very fast. Just a couple of hours ago, I compared two 100-MB files this way, it took less than 3 seconds to run.

$time perl real 0m2.378s user 0m1.384s sys 0m0.069s

Even if they are not sorted, this might still be the solution: first to sort both files and then read them in parallel. The only difficulty is to get the parallel reading really correct.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1056337]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (8)
As of 2018-06-17 22:25 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (107 votes). Check out past polls.