Re: plotting cpu and mem consumption
From: Wim Deprez (wim.deprez+comp.lang.cpp_at_student.luc.ac.be)
Date: 06/18/04
- Next message: E. Robert Tisdale: "Troll Alert: Java's performance far better that optimized C++"
- Previous message: Elly Sokol: "Re: CreateProcess"
- In reply to: Victor Bazarov: "Re: plotting cpu and mem consumption"
- Next in thread: Phlip: "Re: plotting cpu and mem consumption"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Fri, 18 Jun 2004 15:48:00 GMT
Victor Bazarov wrote:
> "Wim Deprez" <wim.deprez+comp.lang.cpp@student.luc.ac.be> wrote...
>
>>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).
>> Does universal code for this problem exist?
>
>
> Probably not. The best thing is to utilise system-specific ways
> of gathering those data (CPU usage) or even use a system-specific
> utility (if memory serves me right, it's called "profiler").
Yeah, I kind of gave up the search to some kind of "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.
I found some examples for the windowssystem:
http://www.codeproject.com/system/cpuusage.asp and
http://www.codeguru.com/Cpp/V-S/debug/article.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.
[...]
> look into using 'clock'. But you'd be much better off
> don't reinvent the wheel but look into using some kind of
> profiling library (or libraries, if no multi-platform one exists).
>
> You should be able to find plenty of interesting libraries in the
> "Available C++ Libraries FAQ" published here about monthly by Nikki
> Locke.
>
ok, I got the clock-function (from time.h:
http://www.cplusplus.com/ref/ctime/clock.html). I probably overlook
something, because I don't exactly get your point, it is not the /time/ that
it takes to run the program, but the amount cpu it uses, it is possible that
other programs are running in the background and such.
So I am looking through the Libraries FAQ, but I didn't find something of a
'profiler', only the 'mpatrol', but that is about debugging dynamically
allocated memory...
And I am still looking for something to measure the memory usage.
>
> Victor
>
Thanks for the tips, I didn't know the Libraries FAQ (quite new to the
group).
Many kind greetings,
--wim
- Next message: E. Robert Tisdale: "Troll Alert: Java's performance far better that optimized C++"
- Previous message: Elly Sokol: "Re: CreateProcess"
- In reply to: Victor Bazarov: "Re: plotting cpu and mem consumption"
- Next in thread: Phlip: "Re: plotting cpu and mem consumption"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|