LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Ways to find Overall CPU Utilization % & Specific Process CPU Utilization %

Hi,

 

I am looking for an option to programmatically get the System CPU usage % and Individual application CPU % as shown in the Task Manager.

 

The use case is to monitor the application performance and take action if memory or CPU usage crosses the threshold limit. I am able to get the memory usage through the "Tasklist" Command line.

 

manig_0-1585834785906.png

 

I explored on few options and most of it points to Processor time using counters from the performance monitor. I am also not able to get an exact relation/formula to compute CPU utilization % from processor time.

 

Attaching links explored,

 

https://forums.ni.com/t5/Example-Code/Monitoring-CPU-usage-on-Windows-from-LabVIEW/ta-p/3520319?prof...

https://forums.ni.com/t5/Example-Code/Reference-Example-of-a-System-Monitor-displaying-CPU-and-Memor...

 

Please let me know if anyone has prior experience or any thoughts on this.

 

Thanks,

Mani.

0 Kudos
Message 1 of 4
(3,724 Views)

If you only need the CPU load, you could try this:

Example_VI.png

 

You can also get memory usage with the same node.

 

This doesn't separate it by process though, and as you see it returns a value for each thread (so 12 on my 6-core laptop).

 

For specific processes, you might try the .NET PerfMon interface/tool: https://forums.ni.com/t5/Example-Code/Performance-Monitor-Using-LabVIEW/ta-p/3501988


GCentral
0 Kudos
Message 2 of 4
(3,709 Views)

Thanks Cbutcher for your reply,

 

I did look at the Resource monitor example shipped with LabVIEW and was not sure how to compute CPU total % as adding up all is higher than 100 and Average doesn't match with the task manager value. Let me know if you have any insights on this.

0 Kudos
Message 3 of 4
(3,702 Views)

Hello everyone,

 

I know this is a somewhat old thread, but I've been looking for a solution for CPU utilization for some time. I had a 32bits DLL (processHandles.dll) that worked exactly as I wanted, but I've moved to 64 bits Labview and can't use it anymore. It allowed to check resources for a specific task, and I used it to save memory and processor usage to disk. I've found a way to read memory using .NET calls, but the processor usage per task is not the same as windows task manager. Does anyone have a solution for this?

0 Kudos
Message 4 of 4
(3,118 Views)