Skip to content

Commit c467eba

Browse files
committed
cli/command/container: calculateCPUPercentWindows minor cleanup
Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 689152a commit c467eba

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

cli/command/container/stats_helpers.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,11 @@ func calculateCPUPercentWindows(v *container.StatsResponse) float64 {
182182
// Max number of 100ns intervals between the previous time read and now
183183
possIntervals := uint64(v.Read.Sub(v.PreRead).Nanoseconds()) // Start with number of ns intervals
184184
possIntervals /= 100 // Convert to number of 100ns intervals
185-
possIntervals *= uint64(v.NumProcs) // Multiple by the number of processors
186-
187-
// Intervals used
188-
intervalsUsed := v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage
185+
possIntervals *= uint64(v.NumProcs) // Multiply by the number of processors
189186

190187
// Percentage avoiding divide-by-zero
191188
if possIntervals > 0 {
189+
intervalsUsed := v.CPUStats.CPUUsage.TotalUsage - v.PreCPUStats.CPUUsage.TotalUsage
192190
return float64(intervalsUsed) / float64(possIntervals) * 100.0
193191
}
194192
return 0.00

0 commit comments

Comments
 (0)