mmkw43
Posts: 554
Joined: Tue Dec 24, 2013 6:18 pm

Raspian CPU monitor?

Fri Jun 19, 2015 3:38 pm

Ok -- have a lengthy python/tkinter program I've been writing and almost done with it, it works great but one thing I hadn't been keeping an eye on is the cpu monitor.

But then, how accurate, what value does it have?

I can reboot, start python, open my program and start it under the command prompt and it will shoot up to 100% -- talking about that little cpu monitor in the upper right corner in raspian, just left of the clock.

What's weird though, is it stays at 100%, even if I close everything -- python included. Like I say, the program runs perfectly -- no errors -- there is a lot going on with 2 threads, and of course tkinter in there also. Is there a better way to see what actually is happening? maybe a command or soemthing I can put in the software that will show me resources being used?

Thought I'd try a PI2 also -- using a model B right now. Guess I may have to just comment out blocks of code to see where the hog is.

ghp
Posts: 1518
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Raspian CPU monitor?

Fri Jun 19, 2015 3:48 pm

Hello,

in a console window, enter 'top'.
'top' is a monitor, which displays processes, cpu per process, memory and some more stuff.

Regards,
Gerhard

mmkw43
Posts: 554
Joined: Tue Dec 24, 2013 6:18 pm

Re: Raspian CPU monitor?

Fri Jun 19, 2015 4:15 pm

thanks --

first entry says 2366 root running about 87% (python 3.2) -- is this the tkinter stuff you think?

ghp
Posts: 1518
Joined: Wed Jun 12, 2013 12:41 pm
Location: Stuttgart Germany
Contact: Website

Re: Raspian CPU monitor?

Fri Jun 19, 2015 4:20 pm

Hello,

the entry is for 'python'. When no other process is using python, then it is tkinter.
Regards,
Gerhard

mmkw43
Posts: 554
Joined: Tue Dec 24, 2013 6:18 pm

Re: Raspian CPU monitor?

Fri Jun 19, 2015 4:54 pm

89 total tasks, 88 sleeping most of the time
(3) running tasks --

(1) top -- of course

and 'python' only shows as a running task very occasionally, as well as 'pi'

177k memory used 268k free

so even with 100% cpu showing, it sounds like I'm ok right? is my situation typical?

mmkw43
Posts: 554
Joined: Tue Dec 24, 2013 6:18 pm

Re: Raspian CPU monitor?

Sat Jun 20, 2015 2:45 am

answering my own post -- apparently it's because I have a nonstop while true loop in my code -- makes sense.

User avatar
davef21370
Posts: 897
Joined: Fri Sep 21, 2012 4:13 pm
Location: Earth But Not Grounded

Re: Raspian CPU monitor?

Sat Jun 20, 2015 4:18 am

Put a small delay in your loop to free up the CPU.

Code: Select all

time.sleep(0.1)
Dave.
Apple say... Monkey do !!

Return to “Python”