From 43569d8d3654cb1a3db661241ebaa9d64793fb13 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 5 May 2017 16:12:17 +0200 Subject: [PATCH] cmd/syncthing: Report correct CPU usage on Windows (fixes #4133) --- cmd/syncthing/gui.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmd/syncthing/gui.go b/cmd/syncthing/gui.go index 9aa3b20b3..4b50a21ad 100644 --- a/cmd/syncthing/gui.go +++ b/cmd/syncthing/gui.go @@ -857,7 +857,10 @@ func init() { return } go func() { - var prevUsage time.Duration + // Initialize prevUsage to an actual value returned by cpuUsage + // instead of zero, because at least Windows returns a huge negative + // number here that then slowly increments... + prevUsage := cpuUsage() for range time.NewTicker(cpuTickRate).C { curUsage := cpuUsage() cpuAverage.Update(int64((curUsage - prevUsage) / time.Millisecond))