1

I am running performance testing on some endpoints on my PC, I would like to see the RAM, hard disk, and CPU usage of the very application that is being used for the performance testing on my computer.

I need a programmable way of setting it up in order to monitor the process under evaluation. I like to start it before the process to be measured starts, and when the process is ended, I then open it up and collate the result. It could be in the form of a graph or just figures on the console. I would appreciate it if someone could help me with how to achieve this.

PS: I am using a Windows computer.

Thanks

Haris_007
  • 11
  • 2
  • Does this answer your question? [Tracking CPU and Memory usage per process](https://stackoverflow.com/questions/69332/tracking-cpu-and-memory-usage-per-process) – Peter Cordes Sep 21 '22 at 10:14
  • Also doesn't seem like a programming question, just a Windows usage question that belongs on https://superuser.com/ where I expect there's a canonical duplicate showing what to look for in Task Manager or Resource Monitor. The Stack Overflow Q&As for getting task manage info are about how to duplicate its output in your own code, e.g. [Continuously monitors the CPU usage % of top X processes](https://stackoverflow.com/q/38551504) or [How to get TaskManager process CPU usage programmatically (not PerfMon API)](https://stackoverflow.com/q/59235746) – Peter Cordes Sep 21 '22 at 10:17
  • I needed a programmable of getting it at the end of the process under evaluation. Like starting it before the process to be measured starts, then when the process is ended, I then go to the code part and collate the result. – Haris_007 Sep 21 '22 at 12:59
  • 1
    You can use WMI, [there's an example on the MS site](https://learn.microsoft.com/en-us/windows/win32/wmisdk/monitoring-performance-data). They way you access WMI/WBEM depends on the language you use. Powershell and .NET have convenient binders. In C you have to use the COM manipulation/quey APIs. – Margaret Bloom Sep 21 '22 at 15:59

2 Answers2

0

you can just open your task manager which gives the processor usage percentage for every app, as well as the memory usage. It also displays the GPU usage for apps which use it.

  • 1
    Yes, this shows it dynamically. I need to get this as a print to show all the different usage points throughout the life cycle of the test. – Haris_007 Sep 21 '22 at 11:26
0

The following solution will require a few minutes if you have not done it before, but it allows you multiple things:

  • Start and Stop it whenever you want (you can also start it from the application directly via system calls if you want to measure very specific parts of your application (attention: each measurement requires time >0ms, and there is a minimum of 1 second pause between different measurements))
  • You can get the results as a graph
  • You can get the results as a CSV file that you can analyze in much more detail

For a programable way, you can use the Get-Counter from powershell (usage and examples for Get-Counter can be found here) and pipe (the character '|') it to Export-Counter (usage and examples for Export-Counter can be found here), which then will export each automatic measurement in a CSV or BLG file. The BLG file, you can directly open as a graph in windows performance monitor. But if you want to write some scripts to calculate specific statistical properties from the data, I would suggest you to export it as a CSV file (hint: you can always transform a CSV file that was generated from Export-Counter via relog generatedFile.csv -o myFileAsPerfmonGraph.blg --format BIN, but this also works the other way).