Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
CPU Status
Message
From
08/09/2006 10:28:17
 
 
To
08/09/2006 09:22:47
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01152193
Message ID:
01152294
Views:
25
This message has been marked as the solution to the initial question of the thread.
> is there exist a WMI Query to ask about process CPU utilization?
> For example, to get an information about my application process only.

Yes, this will measure the processor usage of the current process:
declare Sleep in WIN32API  integer 

nProcessID =  _vfp.processID && or specify one, eg from task manager

oWMIService = getobject("winmgmts:\\")
oItems = oWMIService.ExecQuery ;
	([Select * From Win32_PerfRawData_PerfProc_Process where IDProcess = '] + ;
	transform(nProcessID) + ['])
for each oItem in oItems
	nPercentUsed1 = val(oItem.PercentUserTime)
	nTimeValue1 = val(oItem.TimeStamp_Sys100NS)
next

for nCounter = 1 to 5
	Sleep(100)
	oItems = oWMIService.ExecQuery ;
			([Select * From Win32_PerfRawData_PerfProc_Process where IDProcess = '] + ;
	transform(nProcessID) + ['])
		
	for each oItem in oItems
		nPercentUsed2 = val(oItem.PercentUserTime)
		nTimeValue2 = val(oItem.TimeStamp_Sys100NS)

		if nTimeValue2 - nTimeValue1 = 0
			nPercentProcessorTime = 0
		else
			nPercentProcessorTime = 100 * (nPercentUsed2 - nPercentUsed1) / ;
				(nTimeValue2 - nTimeValue1)
			? transform(nPercentProcessorTime) + "% used"
		endif
		nPercentUsed1 = nPercentUsed2
		nTimeValue1 = nTimeValue2
	next
next
Previous
Reply
Map
View

Click here to load this message in the networking platform