docs: 新增 .qoder Repowiki 知识库文档
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
$ErrorActionPreference = 'Stop'
|
||||
$cpus = (Get-CimInstance Win32_ComputerSystem).NumberOfLogicalProcessors
|
||||
Write-Output "logical_cpus=$cpus"
|
||||
$pat = 'msedgewebview2|ecat_native|pythonw|python'
|
||||
function Snap {
|
||||
$h = @{}
|
||||
foreach ($p in (Get-Process | Where-Object { $_.ProcessName -match $pat })) {
|
||||
$h[[string]$p.Id] = [pscustomobject]@{ name = $p.ProcessName; cpu = $p.CPU; ws = $p.WorkingSet64 }
|
||||
}
|
||||
return $h
|
||||
}
|
||||
$a = Snap
|
||||
Start-Sleep -Seconds 8
|
||||
$b = Snap
|
||||
$dt = 8
|
||||
$rows = foreach ($k in $b.Keys) {
|
||||
if ($a.ContainsKey($k)) {
|
||||
$d = ($b[$k].cpu - $a[$k].cpu)
|
||||
if ($d -gt 0) {
|
||||
[pscustomobject]@{
|
||||
pid = [int]$k
|
||||
name = $b[$k].name
|
||||
pct = [math]::Round($d / $dt * 100, 1)
|
||||
wsMB = [math]::Round($b[$k].ws / 1MB, 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$rows | Where-Object { $_.pct -ge 0.3 } | Sort-Object pct -Descending | Format-Table -AutoSize | Out-String -Width 200 | Write-Output
|
||||
$total = ($rows | Measure-Object -Property pct -Sum).Sum
|
||||
Write-Output ("total_pct_of_one_core=" + [math]::Round($total,1))
|
||||
Reference in New Issue
Block a user