From 78efa6a25c5432f2ad9e9f5c5e922f52830ae30e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A5=A5=E5=88=A9=E5=97=B7=E5=97=B7=E5=97=B7=E5=8F=AB?= Date: Thu, 20 Jun 2024 01:31:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=9B=E7=A8=8Bcpu=E4=BD=BF=E7=94=A8?= =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- android/perf/process.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/android/perf/process.go b/android/perf/process.go index e90c275..af834ce 100644 --- a/android/perf/process.go +++ b/android/perf/process.go @@ -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 } }