100% CPU usage could mean that you are using the system efficiently. However lets assume that is not the case.
You need to look at what your script is doing, there is no magic performance improvement pill. Of course I have no idea what that might be, or how complex the script is. A start would be to profile it using
Devel::DProf to find the bottlenecks, however a small script might just need an inspection.
It could be that CPU is not really an issue, but that you are paging too much, so look at the size of your data structures - particularly if you are reading an entire file into memory. Another common error is creating too many child processes, especially within a loop. Runaway CPU usage might mean an infinite loop, so check your loop exit conditions - and possibly step through using the debugger. Inserting
sleep statements might seem attractive but they can mask other errors.
If you really have no alternative and your script is error free (!) then you can reduce its priority using Windows Task Manager or by calling the Win32 API SetPriorityClass.
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, details, 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, summary, 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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.