Tracking CPU and Memory usage per process

前端 未结 16 2039
粉色の甜心
粉色の甜心 2020-11-28 01:28

I suspect that one of my applications eats more CPU cycles than I want it to. The problem is - it happens in bursts, and just looking at the task manager doesn\'t help me as

相关标签:
16条回答
  • 2020-11-28 02:09

    You might want to have a look at Process Lasso.

    0 讨论(0)
  • 2020-11-28 02:09

    There was a requirement to get status and cpu / memory usage of some specific windows servers. I used below script:

    This is an example of Windows Search Service.

      $cpu = Get-WmiObject win32_processor
      $search = get-service "WSearch"
      if ($search.Status -eq 'Running')
      {
      $searchmem = Get-WmiObject Win32_Service -Filter "Name = 'WSearch'"
      $searchid = $searchmem.ProcessID
      $searchcpu1 = Get-WmiObject Win32_PerfRawData_PerfProc_Process | Where {$_.IDProcess -eq $searchid}
      Start-Sleep -Seconds 1
      $searchcpu2 = Get-WmiObject Win32_PerfRawData_PerfProc_Process | Where {$_.IDProcess -eq $searchid}
      $searchp2p1 = $searchcpu2.PercentProcessorTime - $searchcpu1.PercentProcessorTime
      $searcht2t1 = $searchcpu2.Timestamp_Sys100NS - $searchcpu1.Timestamp_Sys100NS
      $searchcpu = [Math]::Round(($searchp2p1 / $searcht2t1 * 100) /$cpu.NumberOfLogicalProcessors, 1)
      $searchmem = [Math]::Round($searchcpu1.WorkingSetPrivate / 1mb,1)
      Write-Host 'Service is' $search.Status', Memory consumed: '$searchmem' MB, CPU Usage: '$searchcpu' %'
      }
    
      else
      {
      Write-Host Service is $search.Status -BackgroundColor Red
      }
    
    0 讨论(0)
  • 2020-11-28 02:10

    Hmm, I see that Process Explorer can do it, although its graphs are not too convenient. Still looking for alternative / better ways to do it.

    0 讨论(0)
  • 2020-11-28 02:14

    WMI is Windows Management Instrumentation, and it's built into all recent versions of Windows. It allows you to programmatically track things like CPU usage, disk I/O, and memory usage.

    Perfmon.exe is a GUI front-end to this interface, and can monitor a process, write information to a log, and allow you to analyze the log after the fact. It's not the world's most elegant program, but it does get the job done.

    0 讨论(0)
提交回复
热议问题