Is there a way to query or calculate the CPU usage of a single process per each core separately?
For example,
Name - - - - Core1 - Core2 - Core3 - Core4
firefox.exe - 0.5% - - 0.1% - - 0.2% - - 0.3%
I know a program called "Process Explorer" (by Mark Russinovich) that can do this, but how can I do this in C#? I've had a look at the System.Diagnostics
namespace, but I couldn't find anything fitting to my requirements.
Here's a picture of what I'm trying to achieve,
The sar Command We can then view these stats with the help of the sar command. In most machines, sysstat comes pre-installed. However, we can also install it manually using Linux package installers like Yum and Apt. Here, ALL denotes that sar should display the CPU utilization for all cores.
While a stage or stage instance is processing data rows, it can use a large portion of the CPU. You can use the Monitor window to check what percentage of the computer processor is being used by an active stage. To show the percentage of CPU usage, choose Show %CP from the Monitor shortcut menu.
Overall, cores are used to transmit information throughout your computer and allow you to make changes to files. You can speed up the processing time of your CPU by having multiple cores and tinkering with overclocking (which you can read about here).
There is a way to get that information, you will need to use a Kernel Debugger. My suspect were that if the Visual Studio Concurrency Visualizer can get this information to make beautiful reports and visualizations, then you can also get it from the Windows Kernel for you use.
You can see some documentation here http://msdn.microsoft.com/en-us/library/windows/hardware/ff552961(v=vs.85).aspx .
But more interesting things can be found by reversing the Microsoft.ConcurrencyVisualizer.dll that can be found on Visual Studio 2012 installation directory. I think you can also use directly this DLL on your project, although you cannot redeploy it as per http://msdn.microsoft.com/en-US/vstudio/hh857605#files. That DLL is available standalone here http://www.microsoft.com/en-us/download/details.aspx?id=41646.
The idea is to learn how this DLL uses the Kernel Trace to know what Thread was on what Core and replicate it to get accurate statistics. Also, I think that ProcessExplorer does get some stats by using the Kernel Debugger API because the Visual Studio conflicts with it when I start the Concurrency Visualizer tool.
This will be fun and hard to do.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With