From caed610b41b3f8b8f6d35d7e6954ef889bec89b4 Mon Sep 17 00:00:00 2001 From: "liang.che" Date: Fri, 16 Aug 2024 17:11:45 +0800 Subject: [PATCH] =?UTF-8?q?fix(process):=20=E7=A1=AE=E4=BF=9DCPU=E4=BD=BF?= =?UTF-8?q?=E7=94=A8=E7=8E=87=E8=AE=A1=E7=AE=97=E4=B8=BA=E9=9D=9E=E8=B4=9F?= =?UTF-8?q?=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- process/process.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/process/process.go b/process/process.go index bfb6c160..03c62cf8 100644 --- a/process/process.go +++ b/process/process.go @@ -338,6 +338,9 @@ func calculatePercent(t1, t2 *cpu.TimesStat, delta float64, numcpu int) float64 return 0 } delta_proc := calculateBusyTime(t2) - calculateBusyTime(t1) + if delta_proc <= 0 { + return 0 + } overall_percent := ((delta_proc / delta) * 100) * float64(numcpu) return overall_percent }