From 92fa582966aa6acd14b9e13c3849986c07ad16a5 Mon Sep 17 00:00:00 2001 From: Samuel Dobron Date: Thu, 24 Oct 2024 11:47:12 +0200 Subject: [PATCH] XDPBenchResults: split inheritance tree `XDPBenchMeasurements` results used to use `FlowMeasurementResults` as a base class overriding some of its methods because xdp-bench tool doesn't measure CPU usage and so `FlowMeasurementResults` CPU metrics were set to `None`. Recent changes from [0] now expects `FlowMeasurementResults` to use both perf and CPU results. Especially `.{start,end}_timestamp` properties expect CPU metrics to be set and if not, it crashes since not using CPU metrics is "masked" by setting `None` instead of regular result containers. [0] https://github.com/LNST-project/lnst/pull/382 --- .../Results/XDPBenchMeasurementResults.py | 61 +++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/lnst/RecipeCommon/Perf/Measurements/Results/XDPBenchMeasurementResults.py b/lnst/RecipeCommon/Perf/Measurements/Results/XDPBenchMeasurementResults.py index 244592ac4..aa8e89147 100644 --- a/lnst/RecipeCommon/Perf/Measurements/Results/XDPBenchMeasurementResults.py +++ b/lnst/RecipeCommon/Perf/Measurements/Results/XDPBenchMeasurementResults.py @@ -1,20 +1,43 @@ from lnst.RecipeCommon.Perf.Results import ParallelPerfResult -from lnst.RecipeCommon.Perf.Measurements.Results.FlowMeasurementResults import ( - FlowMeasurementResults, +from lnst.RecipeCommon.Perf.Measurements.Results.BaseMeasurementResults import ( + BaseMeasurementResults, ) from lnst.RecipeCommon.Perf.Measurements.MeasurementError import MeasurementError -class XDPBenchMeasurementResults(FlowMeasurementResults): - def __init__(self, *args, **kwargs): - super().__init__(*args, **kwargs) +class XDPBenchMeasurementResults(BaseMeasurementResults): + def __init__(self, measurement, flow, warmup_duration=0): + super().__init__(measurement, warmup_duration) + + self._flow = flow + self._generator_results = ParallelPerfResult() # multiple instances of pktgen self._receiver_results = ParallelPerfResult() # single instance of xdpbench + @property + def flow(self): + return self._flow + @property def metrics(self) -> list[str]: return ['generator_results', 'receiver_results'] + @property + def generator_results(self) -> ParallelPerfResult: + return self._generator_results + + @generator_results.setter + def generator_results(self, value: ParallelPerfResult): + self._generator_results = value + + @property + def receiver_results(self) -> ParallelPerfResult: + return self._receiver_results + + @receiver_results.setter + def receiver_results(self, value: ParallelPerfResult): + self._receiver_results = value + def add_results(self, results): if results is None: return @@ -24,7 +47,33 @@ def add_results(self, results): else: raise MeasurementError("Adding incorrect results.") - def time_slice(self, start, end): + @property + def start_timestamp(self): + return min( + [ + self.generator_results.start_timestamp, + self.receiver_results.start_timestamp, + ] + ) + + @property + def end_timestamp(self): + return max( + [ + self.generator_results.end_timestamp, + self.receiver_results.end_timestamp, + ] + ) + + @property + def warmup_end(self): + return self.start_timestamp+self.warmup_duration + + @property + def warmdown_start(self): + return self.end_timestamp-self.warmup_duration + + def time_slice(self, start, end) -> "XDPBenchMeasurementResults": result_copy = XDPBenchMeasurementResults( self.measurement, self.flow, warmup_duration=0 )