views:

169

answers:

6

Hi, could anyone suggest a way (other than using Task Manager) to track and log a program's usage of CPU and RAM in order to profile its performance?

I'm working under Windows.

Something generic would be useful. A more specific request solution would involve Visual Studio. I've tried Performance Wizard, but it doesn't seem to give me the information I need. Thanks

+1  A: 

Well, there are published APIs for that sort of thing. You might want to take a look at WMI and the Win32_Process class.

If you're looking for a command-line program that gets those things for you there is tasklist and wmic. You can parse their output if you're so inclined.

Joey
+4  A: 

Process Explorer can be useful.

Joseph
does it also serves memory usage?
pistacchio
@pistacchio yes is shows memory usage in a variety of ways.
Joseph
It really seems what I'm looking for, but can it "record" the history of a process or similar?
pistacchio
The Windows Performance Toolkit (described below) builds a record of performance issues, and can capture stack traces of problematic areas.
Eric Brown
A: 

How about Intel VTune?

Kevin Laity
i think that 699$ for something that *nix's top does for free is a bit too much for me, but thanks for the input!
pistacchio
Fair enough, I haven't really used it myself but thought I would throw it out there :)
Kevin Laity
It has been harsh on VTune. It is not suitable for this kind of task but it is not "top" either...
Malkocoglu
VTune is a great profiling tool to make sure your CPU-dependent code is running as fast as it possibly can. It's less useful to find out why your system is slow.
Eric Brown
@Eric: Since this is stackoverflow, my assumption was that he needed to find out why the program he was writing was slow, not his entire system. Otherwise this belongs on serverfault or superuser.
Kevin Laity
+3  A: 

You can use perfmon utility to gather various counters

Naveen
can you record its data or it is onlt runtime?
pistacchio
You can save the counter values and open it later
Naveen
+1  A: 

The Microsoft Platform SDK includes the Windows Performance Toolkit, which tracks CPU, disk, and memory usage over time (along with a ton of other features). It's very handy for tracking down spikes of CPU/memory usage, as well as tracking down issues like why your laptop won't sleep.

Eric Brown
A: 

I view the measuring of performance, and the finding of performance problems so as to make the program faster, as two distinctly different goals.

For measuring, one can use profilers, or simply timers, to get the job done.

For finding performance problems, I take an entirely different approach.

Mike Dunlavey