Skip to content

Commit 841cb4a

Browse files
authored
Merge pull request kubernetes#99844 from minbaev/scheduler-test-perf-optimization
add if check for number of scheduled pods to be greater than 0
2 parents 40d8aed + 359116f commit 841cb4a

File tree

1 file changed

+8
-5
lines changed
  • test/integration/scheduler_perf

1 file changed

+8
-5
lines changed

test/integration/scheduler_perf/util.go

+8-5
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,15 @@ func (tc *throughputCollector) run(ctx context.Context) {
256256
}
257257

258258
scheduled := len(podsScheduled)
259-
samplingRatioSeconds := float64(throughputSampleFrequency) / float64(time.Second)
260-
throughput := float64(scheduled-lastScheduledCount) / samplingRatioSeconds
261-
tc.schedulingThroughputs = append(tc.schedulingThroughputs, throughput)
262-
lastScheduledCount = scheduled
259+
// Only do sampling if number of scheduled pods is greater than zero
260+
if scheduled > 0 {
261+
samplingRatioSeconds := float64(throughputSampleFrequency) / float64(time.Second)
262+
throughput := float64(scheduled-lastScheduledCount) / samplingRatioSeconds
263+
tc.schedulingThroughputs = append(tc.schedulingThroughputs, throughput)
264+
lastScheduledCount = scheduled
265+
klog.Infof("%d pods scheduled", lastScheduledCount)
266+
}
263267

264-
klog.Infof("%d pods scheduled", lastScheduledCount)
265268
}
266269
}
267270
}

0 commit comments

Comments
 (0)