import com
import console
var objWMIService = com.GetObject("winmgmts:\\.\root\cimv2")
var colItems = objWMIService.ExecQuery("SELECT * FROM Win32_PerfFormattedData_PerfProc_Process")
for i,objItem in com.each(colItems) {
console.log(objItem.getName(), objItem.getPercentProcessorTime(), objItem.getPrivateBytes())
}
execute("pause")
Some gotchas: 当前程序占用的内存 PrivateBytes指的是current number of bytes this process has allocated that cannot be shared with other processes,其他还有WorkingSet、WorkingSetPeak、VirtualBytes、VirtualBytesPeak、......,各有不同意思。 当前程序占用的CPU The values via directly reading PercentProcessorTime, PercentPrivilegedTime, or PercentUserTime may be not what you want. Please refer to http://blogs.technet.com/b/heyscriptingguy/archive/2005/04/21/why-does-my-performance-monitoring-script-keep-returning-the-same-incorrect-values.aspx |