Skip to content

Commit

Permalink
XDPBenchResults: split inheritance tree
Browse files Browse the repository at this point in the history
`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] #382
enhaut authored and olichtne committed Oct 30, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 212cc2e commit 92fa582
Showing 1 changed file with 55 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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
)

0 comments on commit 92fa582

Please sign in to comment.