Display threads usage which take more then 10 seconds.
AdbThreadProc 11324 | where 'UserTime' -gt 10 | foreach { $_.ThreadName + "," + $_.UserTime }
# Display process threads information | |
function AdbProcessInfo($processId) { | |
adb shell cat /proc/$processId/task/*/stat | |
} | |
# Displays user time for the threads in the specific Android process | |
function AdbThreadProc($processId) | |
{ | |
AdbProcessInfo($processId) | Where-Object { $_ -match '(\d+)\s'} | foreach { | |
$data = $_.ToString() -replace '(\d+)\s\(([^)]*?)\)\s\w\s([0-9\-]*\s){10}(\d+).*', '${1},${2},${4}' | |
$data = $data.Split(",") | |
$info = @{} | |
$info.PID= [int]$data[0] | |
$info.ThreadName=$data[1] | |
$info.UserTime= [int]$data[2] | |
$object = New-Object –TypeName PSObject –Prop $info | |
Write-Output $object | |
} | Sort-object UserTime -desc | |
} |