diff options
Diffstat (limited to 'resources/libraries/python')
-rw-r--r-- | resources/libraries/python/DropRateSearch.py | 11 | ||||
-rw-r--r-- | resources/libraries/python/TrafficGenerator.py | 31 |
2 files changed, 34 insertions, 8 deletions
diff --git a/resources/libraries/python/DropRateSearch.py b/resources/libraries/python/DropRateSearch.py index b0f15b25db..6346125592 100644 --- a/resources/libraries/python/DropRateSearch.py +++ b/resources/libraries/python/DropRateSearch.py @@ -99,6 +99,15 @@ class DropRateSearch(object): self._search_result_rate = None @abstractmethod + def get_latency(self): + """Return min/avg/max latency. + + :return: Latency stats. + :rtype: list + """ + pass + + @abstractmethod def measure_loss(self, rate, frame_size, loss_acceptance, loss_acceptance_type, traffic_type): """Send traffic from TG and measure count of dropped frames. @@ -460,7 +469,7 @@ class DropRateSearch(object): raise Exception('Search FAILED') elif self._search_result in [SearchResults.SUCCESS, SearchResults.SUSPICIOUS]: - return self._search_result_rate, self._latency_stats + return self._search_result_rate, self.get_latency() def binary_search(self, b_min, b_max, traffic_type, skip_max_rate=False): """Binary search of rate with loss below acceptance criteria. diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 0388179876..2a94912860 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -47,9 +47,6 @@ class TGDropRateSearchImpl(DropRateSearch): tg_instance.trex_stl_start_remote_exec(self.get_duration(), unit_rate, frame_size, traffic_type) - # Get latency stats from stream - self._latency_stats = tg_instance.get_latency() - loss = tg_instance.get_loss() sent = tg_instance.get_sent() if self.loss_acceptance_type_is_percentage(): @@ -66,6 +63,16 @@ class TGDropRateSearchImpl(DropRateSearch): else: raise NotImplementedError("TG subtype not supported") + def get_latency(self): + """Return min/avg/max latency. + + :return: Latency stats. + :rtype: list + """ + + tg_instance = BuiltIn().get_library_instance( + 'resources.libraries.python.TrafficGenerator') + return tg_instance.get_latency_int() class TrafficGenerator(object): """Traffic Generator.""" @@ -107,8 +114,8 @@ class TrafficGenerator(object): """ return self._received - def get_latency(self): - """Return min/avg/max latency. + def get_latency_int(self): + """Return rounded min/avg/max latency. :return: Latency stats. :rtype: list @@ -476,9 +483,19 @@ class TrafficGenerator(object): self._received = self._result.split(', ')[1].split('=')[1] self._sent = self._result.split(', ')[2].split('=')[1] self._loss = self._result.split(', ')[3].split('=')[1] + self._latency = [] - self._latency.append(self._result.split(', ')[4].split('=')[1]) - self._latency.append(self._result.split(', ')[5].split('=')[1]) + lat_int_list = [] + #round latency numbers + lat_str = self._result.split(', ')[4].split('=')[1] + for lat in lat_str.split("/"): + lat_int_list.append(int(float(lat))) + self._latency.append("/".join(str(tmp) for tmp in lat_int_list)) + lat_int_list = [] + lat_str = self._result.split(', ')[5].split('=')[1] + for lat in lat_str.split("/"): + lat_int_list.append(int(float(lat))) + self._latency.append("/".join(str(tmp) for tmp in lat_int_list)) def stop_traffic_on_tg(self): """Stop all traffic on TG |