Hello,
I want to log CPU usage & memory usage of my code (run it via Visual studio, windows 10).
I found performance monitor, and want to know how to use it.
My question is: which counter is CPU usage and which one is memory usage?
Or Is there any user guide, manual or reference?
I logged some counts in this way:
Performance monitor > Data Collector Sets > User Defined > right click > new > Data Collector Set >
Create manually > Next > Create data logs, v Performance counter > Next > Add >
Process > % User Time > my program to log CPU usage,
Process > Private Bytes > my program to log memory usage.
Also set time, and I saved as csv file.
Is that right to select '% User Time' and 'Private Bytes' to see the CPU usage and Memory usage?
According to the description,
% User Time is
the percentage of elapsed time that the process threads spent executing code in user mode. Applications, environment subsystems, and integral subsystems execute in user mode. Code executing in user mode cannot damage the integrity of the Windows executive, kernel, and device drivers. Unlike some early operating systems, Windows uses process boundaries for subsystem protection in addition to the traditional protection of user and privileged modes. Some work done by Windows on behalf of the application might appear in other subsystem processes in addition to the privileged time in the process.
Private Bytes is
the current size, in bytes, of memory that this process has allocated that cannot be shared with other processes.
However, they seems quite different from what I can see in the Task Manager.
For example,
Task manager says CPU usage of my program is 7%, but Performance Monitor says % User Time is 45%.
Also, Task manager says Memory usage is ~390MB but Performance Monitor, is about 430MB (~446000000 bytes. I divided this value by 1024 twice to scale it. There is no information of unit, but it should be bytes I guess..am I right?)
Please let me know if you need further information.
Thank you in advance!
Best wishes,
JESuh