I was judging by the criteria that you provided: You wanted the make your program faster. Are you now saying you want to slow down your program to give other programs more CPU time? If so, use nice as previously mentioned.
| [reply] [d/l] |
I want to know the reason why cpu usage is 100%. how to make a execution more fast without consuming 100% cpu. or maybe i have doing something wrong that can i avoided have you u seen my sudo code ?
| [reply] |
I want to know the reason why cpu usage is 100%. how to make a execution more fast without consuming 100% cpu. or maybe i have doing something wrong that can i avoided have you u seen my sudo code ?
Since you haven't shown the actual code you're running (or any input data), or at least a representative sample (SSCCE), we unfortunately can't tell you why your code is running "slow" (Update: there might not even be a way to significantly speed it up without different hardware). For now, we can just tell you how to measure it yourself (e.g. Devel::NYTProf). There could be things you're doing in code that you haven't shown here that are slowing it down (for example, you didn't show the code you use to split the @lines array into chunks, except that you might be using string concatenation, and you haven't explained why you've got a @lines array in the first place, instead of a while(<$filehandle>) loop).
| [reply] [d/l] [select] |
It's running at 100% because it doesn't waste time waiting for the disk, waiting for packets, etc.
Again, making it use less CPU will necessarily make it slower
And yes, I saw your pseudocode. It says you are parsing and extracting data from 100,000 XML documents in 2.5 minutes, which is one every 0.015 seconds, which I think is quite fast.
If you really want to reduce the time needed, you should rethink how you store your data in order to avoid parsing 100,000 XML documents. Alternately, parallelize the program and throw more CPUs at it. (For example, Having 10 cores do 10,000 XML docs each could reduce the time from 2.5 minutes to as little as 15 seconds.)
| [reply] |