plotting cpu and mem consumption

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2004
Posts: 3
Reputation: vvim is an unknown quantity at this point 
Solved Threads: 0
vvim vvim is offline Offline
Newbie Poster

plotting cpu and mem consumption

 
2
  #1
Jun 16th, 2004
Hi Group,

for a project[1] I am trying to find an OS independant way to measure the amount of cpu usage and memory consumption of the program. It would be nice if I could do that in my C++ code, so I can show the results at runtime or even plot a nice graph (I got wild dreams).

After some google'ing I found some (nice) examples[2] but they are all windows based. Does universal code for this problem exist?

Of course I can make different classes (one for windows and another for *nix), I do something similar to assign sockets. But then I also need code for *nix, without using bash-scripting of course.

So I am looking for something OS independant, but examples for windows or *nix can help me out for now as well.

Goodnight everyone and thanks in advance,

--wim
______
[1] I am trying to compare some differint multicast protocols, and yes, also cpu usage and memory consumption is an important part of that :-)
[2] if anybody wants them, I can always post links, just ask
Reply With Quote Quick reply to this message  
Join Date: May 2003
Posts: 307
Reputation: big_k105 is an unknown quantity at this point 
Solved Threads: 2
Team Colleague
big_k105's Avatar
big_k105 big_k105 is offline Offline
PFO Founder

Re: plotting cpu and mem consumption

 
1
  #2
Jun 17th, 2004
im not thinking you will find universal code for what you want to do. but good luck on your search i will keep an eye open for you
Reply With Quote Quick reply to this message  
Join Date: Mar 2004
Posts: 1,620
Reputation: kc0arf is a jewel in the rough kc0arf is a jewel in the rough kc0arf is a jewel in the rough 
Solved Threads: 51
Team Colleague
kc0arf kc0arf is offline Offline
Posting Virtuoso

Re: plotting cpu and mem consumption

 
1
  #3
Jun 17th, 2004
Hello,

There are some ways to do this.

For CPU monitoring (and network), you can look into a package called mrtg that can be setup to monitor CPU processes, and graph it out. It will require you to setup snmpd and other things in order to get it to function properly.

For code, and how much CPU you use, check out your compiler to see if it supports profiling. I did that for COBOL code on a VAX/VMS, and for C++ on my Macintosh. Found out what functions used the most CPU time, and how long it took to do them. I liked profiling sorts, and comparing quicksort vs. bubble sort and the like.

Now, I know it isn't cross-platform, but the profiling might be the most efficient and non-skewing of the techniques. Why? because it is built into the compiler environment, and I am sure that the program coders took that into account.

Christian
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 3
Reputation: vvim is an unknown quantity at this point 
Solved Threads: 0
vvim vvim is offline Offline
Newbie Poster

Re: plotting cpu and mem consumption

 
0
  #4
Jun 18th, 2004
BigK: Yeah, I kind of gave up the search to "universal code" (I just like the sound of it (-. I guess I'll have to write separate implementations for each OS and use conditional compile statements in the source code.

kc0arf: the problem is that I want to do it at run time, in the code itself. the idea is that my program plots a graph (or make a log file, whatever), so every (future) user can see how much resources a protocol uses, without needing to know to go to the /proc-dir

Another major problem is that I haven't found interesting code concerning the memory consumption. Until know, I only found ways to measure CPU-cycles and only for windows. Can anyone help me?

Many kind greetings and thanks in advance,

--wim deprez
Reply With Quote Quick reply to this message  
Join Date: May 2004
Posts: 256
Reputation: FireNet will become famous soon enough FireNet will become famous soon enough 
Solved Threads: 6
FireNet's Avatar
FireNet FireNet is offline Offline
Posting Whiz in Training

Re: plotting cpu and mem consumption

 
0
  #5
Jun 18th, 2004
You could try looking in *nix development fourms.Also try looking in google.You will definately find good info if you search properly.
See what you can, remember what you need

Fourzon | Earn via Coding
Reply With Quote Quick reply to this message  
Join Date: Jun 2004
Posts: 3
Reputation: vvim is an unknown quantity at this point 
Solved Threads: 0
vvim vvim is offline Offline
Newbie Poster

Re: plotting cpu and mem consumption

 
0
  #6
Jun 18th, 2004
Well I guess that is my problem then, I first started looking in to Google, but didn't find anything satisfacting to my needs, that is why I started posting on forums. Maybe I do not use the right words to query.

I found some examples for the windowssystem:
http://www.codeproject.com/system/cpuusage.asp and
http://www.codeguru.com/Cpp/V-S/debu...cle.php/c4415/ . Now I am
wondering if it would be a bad idea to use a filepointer to read the
/proc/stat in *nix systems. For now, it is the only posibility I can come up
with. If somebody has a better idea, you're welcome.

And then I still need to find a good solution to check the memory usage. At comp.lang.c++ they referred me to the "Available C++ Libraries FAQ" by Nikki Locke (http://www.trumphurst.com/cpplibs/cpplibs.phtml) but I couldn't find a solution.

Thanks for your help, but I am still on my quest :-)

Many kind greetings,

--wim deprez
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 3
Reputation: zeah is an unknown quantity at this point 
Solved Threads: 0
zeah zeah is offline Offline
Newbie Poster

Re: plotting cpu and mem consumption

 
0
  #7
Apr 6th, 2008
hi
i need to compute the cpu usage time for my function calls...how do i do that in linux with C++ as my programming language.
Thanks in advance.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1
Reputation: codigo is an unknown quantity at this point 
Solved Threads: 0
codigo codigo is offline Offline
Newbie Poster

Re: plotting cpu and mem consumption

 
0
  #8
Aug 7th, 2008
hi
I have similar problem. Propably even more difficult I'd like to measure processor usage while my application is working but on windows mobile. Moreover I'd like to write my own class to do it. Have you got some ideas?
Last edited by codigo; Aug 7th, 2008 at 6:49 am.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 1,493
Reputation: William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of William Hemsworth has much to be proud of 
Solved Threads: 123
Sponsor
William Hemsworth William Hemsworth is offline Offline
Nearly a Posting Virtuoso

Re: plotting cpu and mem consumption

 
0
  #9
Aug 7th, 2008
Stop posting in this thread o.0 its 4 years old.
I need pageviews! most fun profile ever :)
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the C++ Forum


Views: 4395 | Replies: 8
Thread Tools Search this Thread



Tag cloud for C++
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC