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

Re: Media Player - CPU Usage

by SuicideJunkie (Priest)
on Nov 28, 2012 at 19:01 UTC ( #1006092=note: print w/ replies, xml ) Need Help??


in reply to Media Player - CPU Usage

You're using up 100% of one of the cores checking the conditions of the while loop as fast as possible. You need to sleep between checks.

while ('blah') { sleep 1; # in seconds select(undef,undef,undef, 0.1); # Or doze off for fractional seconds }

Should do. Adjust the numbers depending on how much CPU you want to spend vs how quickly you want to notice that the loop condition has changed.


Comment on Re: Media Player - CPU Usage
Download Code
Re^2: Media Player - CPU Usage
by roho (Monsignor) on Nov 28, 2012 at 22:08 UTC
    Thank you! Adding sleep 1 took care of the problem. As Lotus1 pointed out below, the synopsis includes sleep 1, but it is withing an infinite while loop.

    "Its not how hard you work, its how much you get done."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1006092]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2014-07-22 23:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (130 votes), past polls