Skip to content

Commit

Permalink
进程cpu使用优化
Browse files Browse the repository at this point in the history
  • Loading branch information
aoliaoaoaojiao committed Jun 19, 2024
1 parent 6fe73fe commit 78efa6a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion android/perf/process.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,17 @@ func GetTotalCpuTime(device *gadb.Device) (float64, error) {
for scanner.Scan() {
line := scanner.Text()
fields := strings.Fields(line)

if len(fields) > 0 && strings.HasPrefix(fields[0], "cpu") { // changing here if you want to get every cpu-core's stats
parseCPUFields(fields, &nowCPU)
var tempCPU entity.SystemCpuRaw
parseCPUFields(fields, &tempCPU)
nowCPU.User += tempCPU.User
nowCPU.Nice += tempCPU.Nice
nowCPU.System += tempCPU.System
nowCPU.Idle += tempCPU.Idle
nowCPU.Iowait += tempCPU.Iowait
nowCPU.Irq += tempCPU.Irq
nowCPU.SoftIrq += tempCPU.SoftIrq
}
}

Expand Down

0 comments on commit 78efa6a

Please sign in to comment.