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??
Dear Monks,

I have a very big input file of around 5590600 MB size and while opening the file and reading the file it is taking 99 or 100% utilisation of my CPU. But I am trying to reduce the CPU utilisation to less than 50% and not able to succeed with that. In the execution of "top" command in command prompt first it says CPU usage: 28.2% but in the detailed PID it says 100% usage. So not sure if it is really taking 100% or only 28%.If it is taking only 28% of overall 100% CPU then it is fine. Else could you please let me know how to reduce the cpu time to less than 50%
tie @lines, 'Tie::File', "testfile.dat" or die "Can't read file: $!\n" +; $linecount = $#lines+1; #print "Linecount=> $linecount\n"; foreach ( @lines ) { chomp; ($type, $No, $date) = split(/\|/); $hash{$No.$date} = $type."@".$No."@".$date; } untie @lines;
PROCESS TIME Processes: 135 total, 4 running, 6 stuck, 125 sleeping, 926 threads + + + 21:13:58 Load Avg: 1.22, 1.17, 1.07 CPU usage: 28.2% user, 3.32% sys, 68.64% i +dle SharedLibs: 10M resident, 9736K data, 0B linkedit. MemRegions: +28168 total, 2921M resident, 76M private, 568M shared. PhysMem: 1056M + wired, 3782M active, 971M inactive, 5810M used, 2380M free. VM: 318G vsize, 1054M framework vsize, 248025(0) pageins, 0(0) pageout +s. Networks: packets: 453919/88M in, 393620/58M out. Disks: 65480/378 +2M read, 137948/7081M written. PID COMMAND %CPU TIME #TH #WQ #PORT #MREGS RPR +VT RSHRD RSIZE VPRVT VSIZE PGRP PPID STATE UID FA +ULTS COW MSGSENT MSGRECV SYSBSD SYSMACH CSW + PAGEINS KPRVT KSHRD USER perl5.12 99.9 00:08.58 1/1 0 22 56+ 99M+ 124 +4K

In reply to Reduce CPU utilization time in reading file using perl by madtoperl

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 admiring the Monastery: (5)
As of 2024-04-18 00:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found