Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Comment on

( #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

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [ambrus]: Today I accidentally cut my hand while carrying a computer. On the display part of the motherboard that sticks out at the back of the chasis and has ports, there's this thin metal sheet with holes cut for the ports, to guide plugs into the sockets.
    [ambrus]: This sheet has sharp needle-like parts, 0.004 long and less than 0.001 wide, that can get bent to point outwards, and one of these cut into my palm when I lifted the box.
    [ambrus]: So now when I choose what motherboard to buy for my new home computer, I have one more specific property to guide me. Useful, because there's so many different boards to choose from.

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (10)
    As of 2017-01-16 19:36 GMT
    Find Nodes?
      Voting Booth?
      Do you watch meteor showers?

      Results (151 votes). Check out past polls.