| MM |
March 24th, 2008, 08:13 AM
Hello,
I have written a simple CPU monitor in python using cairo and pango.
It is my first real program, it has a pleasant interface and all that. I am just learning python, and i have no real prior experience except for a Java 101 a few years back at uni.
My prog is called Jiffy, because that's the name given to the most basic time interval in the kernel, and apparently that's the unit used in /proc/stat to record cpu time doing stuff -- or not doing stuff as it may be.
I am kinda confused about the actual value of a jiffy, originally i read it was 10 ms but then i found another article that said from kernel 2.6.x on a jiffy was now 4ms. So not sure about that one, any insight appreciated.
Given this confusion, I suspect my y values are based on a wrong assumption, but i am too tired to think it through right now. The values are still indicative and more or less match what top is seeing.
I was motivated to write a CPU monitor because the current g-s-m is crap on my pc, a total cpu hog, like > 50% when it renders the graphs. Jiffy is better, it runs at around 5-6% cpu according to top, given python and the amount of cairo i am quite happy, though i am sure improvements can be made in many places.
This Easter break, writing Jiffy and learning about python has been a thoroughly satisfying experience.
It seems to be crash free at this point, so hopefully it'll run on other systems :P. I am using the nvidia proprietary drivers, so i am not sure about cairo performance on other systems. Also of note is the fact i wrote it on hardy, i am not sure (because i can't test) if this means older version of python or cairo will spew errors.
I would appreciate any feedback on any aspect of my code, be it my algorithms, best practice or style.
I've attached some screenshots as well as the source. :)
http://ubuntuforums.org/attachment.php?attachmentid=63622&stc=1&d=1206342454
I wish to thank all those who have put tutorials on the net, giving examples of how to use python, gtk, cairo and pango.
Finally, I have found the following sites especially useful:
http://www.pygtk.org/pygtk2tutorial/index.html
http://www.tortall.net/mu/wiki/CairoTutorial
http://aruiz.typepad.com/siliconisland/2006/04/threads_on_pygt.html
http://www.pygtk.org/articles/cairo-pygtk-widgets/cairo-pygtk-widgets2.htm
I have written a simple CPU monitor in python using cairo and pango.
It is my first real program, it has a pleasant interface and all that. I am just learning python, and i have no real prior experience except for a Java 101 a few years back at uni.
My prog is called Jiffy, because that's the name given to the most basic time interval in the kernel, and apparently that's the unit used in /proc/stat to record cpu time doing stuff -- or not doing stuff as it may be.
I am kinda confused about the actual value of a jiffy, originally i read it was 10 ms but then i found another article that said from kernel 2.6.x on a jiffy was now 4ms. So not sure about that one, any insight appreciated.
Given this confusion, I suspect my y values are based on a wrong assumption, but i am too tired to think it through right now. The values are still indicative and more or less match what top is seeing.
I was motivated to write a CPU monitor because the current g-s-m is crap on my pc, a total cpu hog, like > 50% when it renders the graphs. Jiffy is better, it runs at around 5-6% cpu according to top, given python and the amount of cairo i am quite happy, though i am sure improvements can be made in many places.
This Easter break, writing Jiffy and learning about python has been a thoroughly satisfying experience.
It seems to be crash free at this point, so hopefully it'll run on other systems :P. I am using the nvidia proprietary drivers, so i am not sure about cairo performance on other systems. Also of note is the fact i wrote it on hardy, i am not sure (because i can't test) if this means older version of python or cairo will spew errors.
I would appreciate any feedback on any aspect of my code, be it my algorithms, best practice or style.
I've attached some screenshots as well as the source. :)
http://ubuntuforums.org/attachment.php?attachmentid=63622&stc=1&d=1206342454
I wish to thank all those who have put tutorials on the net, giving examples of how to use python, gtk, cairo and pango.
Finally, I have found the following sites especially useful:
http://www.pygtk.org/pygtk2tutorial/index.html
http://www.tortall.net/mu/wiki/CairoTutorial
http://aruiz.typepad.com/siliconisland/2006/04/threads_on_pygt.html
http://www.pygtk.org/articles/cairo-pygtk-widgets/cairo-pygtk-widgets2.htm