是否有命令行实用程序来显示WS专用字节? [英] Is there a command line utility to display the WS private bytes?
问题描述
在Process Explorer中,它是 WS专用字节,而在Task Manager中,它是私有工作集.
In Process Explorer terms it is WS Private Bytes, whereas in Task Manager terms it is Private Working Set.
我希望命令行实用程序在给定进程名称的情况下显示此信息.
I would like a command line utility to display this information given a process name.
编辑
powershell脚本也可以.
A powershell script will do as well.
推荐答案
在PowerShell
中,您可以使用:
function ProcessInfo
{
param
([String]$processName)
$workingSet = get-counter -counter "\Process($processName)\Working Set - Private" | select -expandproperty countersamples | select cookedvalue
$privateBytes = get-counter -counter "\Process($processName)\Private Bytes" | select -expandproperty countersamples | select cookedvalue
get-process $processName | select `
name, `
@{Name="Private Working Set"; Expression = {$workingSet.CookedValue}},`
@{Name="WS Private Bytes"; Expression = {$privateBytes.CookedValue}}
}
ProcessInfo("winrar")
这是一个改进的版本,它以进程ID作为参数.
Here's an improved version which takes the process id as a parameter.
function GetProcessInfoById
{
param
([int]$processId)
Get-WmiObject -class Win32_PerfFormattedData_PerfProc_Process | where{$_.idprocess -eq $processId} | select `
@{Name="Process Id"; Expression = {$_.idprocess}},`
@{Name="Counter Name"; Expression = {$_.name}},`
@{Name="Private Working Set"; Expression = {$_.workingSetPrivate / 1kb}}
}
GetProcessInfoById 380
这是一个以进程名称为参数的版本.这可能会返回多个值(每个流程实例一个),您可以通过Process Id
的值来标识流程.
And here's an version which takes the process name as a parameter. This may return multiple values (one for each instance of the process) and you can identify processes by the values by the Process Id
.
function GetProcessInfoByName
{
param
([string]$processName)
Get-WmiObject -class Win32_PerfFormattedData_PerfProc_Process | where{$_.name -like $processName+"*"} | select `
@{Name="Process Id"; Expression = {$_.idprocess}},`
@{Name="Counter Name"; Expression = {$_.name}},`
@{Name="Private Working Set"; Expression = {$_.workingSetPrivate / 1kb}}
}
GetProcessInfoByName svchost
这篇关于是否有命令行实用程序来显示WS专用字节?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!