From b28c1392d7edfa07029dc76b6f9bfeef4dfc8856 Mon Sep 17 00:00:00 2001 From: Kevin Klues Date: Tue, 23 Nov 2021 20:27:54 +0000 Subject: [PATCH] Round the CPUManager mean and stddev calculations to the nearest 1000th Signed-off-by: Kevin Klues --- pkg/kubelet/cm/cpumanager/cpu_assignment.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/kubelet/cm/cpumanager/cpu_assignment.go b/pkg/kubelet/cm/cpumanager/cpu_assignment.go index df6cc3b8265..696bafca8dd 100644 --- a/pkg/kubelet/cm/cpumanager/cpu_assignment.go +++ b/pkg/kubelet/cm/cpumanager/cpu_assignment.go @@ -65,7 +65,8 @@ func mean(xs []int) float64 { for _, x := range xs { sum += float64(x) } - return sum / float64(len(xs)) + m := sum / float64(len(xs)) + return math.Round(m*1000) / 1000 } func standardDeviation(xs []int) float64 { @@ -74,7 +75,8 @@ func standardDeviation(xs []int) float64 { for _, x := range xs { sum += (float64(x) - m) * (float64(x) - m) } - return math.Sqrt(sum / float64(len(xs))) + s := math.Sqrt(sum / float64(len(xs))) + return math.Round(s*1000) / 1000 } func min(x, y int) int {