From af6da561dd88b09ee0e38b0191a4750b5fc2ef7a Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 8 Sep 2025 14:12:18 +0200 Subject: [PATCH] scheduler_perf: reset and stop testing.B metrics Before, metrics gathered by testing.B (runtime_seconds, -benchmem's B/op and allocs/op) covered the entire test case, including starting the apiserver and the initialization steps of a workload. Now those metrics are also limited to the period where the workload is configured to collect metrics. --- test/integration/scheduler_perf/scheduler_perf.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/integration/scheduler_perf/scheduler_perf.go b/test/integration/scheduler_perf/scheduler_perf.go index 4c4c2c30bfe..f539941b5e9 100644 --- a/test/integration/scheduler_perf/scheduler_perf.go +++ b/test/integration/scheduler_perf/scheduler_perf.go @@ -1463,10 +1463,17 @@ func startCollectingMetrics(tCtx ktesting.TContext, collectorWG *sync.WaitGroup, collector.run(collectorCtx) }() } + if b, ok := tCtx.TB().(*testing.B); ok { + b.ResetTimer() + } + tCtx.Log("Started metrics collection") return collectorCtx, collectors, nil } func stopCollectingMetrics(tCtx ktesting.TContext, collectorCtx ktesting.TContext, collectorWG *sync.WaitGroup, threshold float64, tms thresholdMetricSelector, opIndex int, collectors []testDataCollector) ([]DataItem, error) { + if b, ok := tCtx.TB().(*testing.B); ok { + b.StopTimer() + } if collectorCtx == nil { return nil, fmt.Errorf("missing startCollectingMetrics operation before stopping") } @@ -1481,6 +1488,7 @@ func stopCollectingMetrics(tCtx ktesting.TContext, collectorCtx ktesting.TContex tCtx.Errorf("op %d: %s", opIndex, err) } } + tCtx.Log("Stopped metrics collection") return dataItems, nil }