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 )