From 6b5e52b270b5b9388458e5621d2fe8c0773c6ef9 Mon Sep 17 00:00:00 2001 From: Douglas Raillard Date: Wed, 5 Apr 2023 19:13:22 +0100 Subject: [PATCH] lisa.tests.scheduler.sanity: Fix use of collector FIX CapacitySanity._from_target() was reusing the passed collector multiple times, leading to only the last trace being saved. Instead, use the collector once and do all the work while collecting. --- lisa/tests/scheduler/sanity.py | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/lisa/tests/scheduler/sanity.py b/lisa/tests/scheduler/sanity.py index 6fabcbfaf..ee2b58793 100644 --- a/lisa/tests/scheduler/sanity.py +++ b/lisa/tests/scheduler/sanity.py @@ -18,7 +18,7 @@ import sys from lisa.target import Target -from lisa.utils import ArtifactPath +from lisa.utils import ArtifactPath, group_by_value from lisa.tests.base import TestMetric, ResultBundle, TestBundle from lisa.wlgen.sysbench import Sysbench @@ -47,16 +47,19 @@ class CapacitySanity(TestBundle): with target.cpufreq.use_governor("performance"): sysbench = Sysbench(target, res_dir=res_dir) + def run(cpu): + output = sysbench(cpus=[cpu], max_duration_s=1).run() + return output.nr_events + cpu_capacities = target.sched.get_capacities() - capa_work = {capa: sys.maxsize for capa in list(cpu_capacities.values())} - for cpu in list(cpu_capacities.keys()): - with collector: - output = sysbench(cpus=[cpu], max_duration_s=1).run() - # We could save the work done on each CPU, but we can make - # things simpler and just store the smallest amount of work done - # per capacity value. - capa = cpu_capacities[cpu] - capa_work[capa] = min(capa_work[capa], output.nr_events) + capacities = group_by_value(cpu_capacities) + + with collector: + capa_work = { + capa: min(map(run, cpus)) + for capa, cpus in capacities.items() + } + return cls(res_dir, target.plat_info, capa_work) -- GitLab