I want to get the CPU Usage for a particular process.
QTP Provides some options like
<font class="small">Code:</font><hr /><pre>
SystemMonitor.GetValue("javaw","% Processor Time")
But here no options for CPU Usage but only for Memory Usage.
Anybody know how can I get CPU Usage. or Any other methods?
I would appreciate If any one help on this!!!
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set AllItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfOS_Processor WHERE Name = '_Total'")
for each itm in AllItems
WScript.Echo itm.PercentProcessorTime & "%"
[ QUOTE ]
But here I want to get CPU Usage not CPU Time. Refer the screenshot attached.
[/ QUOTE ]
The problem with the CPU Useage in your screenshot is that it's since the last sample time (I'm assuming this screenshot is from Task Manager) and its not linked to CPU time. so A Process can be using 50% of CPU for one sample and 0% for the next sample.
How are you hoping to use this as there may be a more useful counter to use rather than this one?
Thanks Mark Smith.
Actually I want to Sync my application after each step. For this I will execute my step, will loop by checking CPU Usage with some delay and then If CPU Usage goes to zero, I will continue to next step.
This is my requirement. SO I thought CPU Usage is better choice. Any thoughts?
Correct me if I am wrong here.