diff options
author | Miroslav Miklus <mmiklus@cisco.com> | 2016-09-20 16:43:19 +0200 |
---|---|---|
committer | Peter Mikus <pmikus@cisco.com> | 2016-09-24 02:36:24 +0000 |
commit | 030f0dff4adbb5da9be2a18cbafec9b077a6723f (patch) | |
tree | 79294b062c3aafb28d2c80e9e601c718992bd4aa | |
parent | 5890588ad2d15c82ca49e0fcf6b2944c71c48501 (diff) |
CSIT-412 replace latency (N/A) string by number -1
Change-Id: Id6373d3bbfcc42e315976b59aa86c6cadee411f1
Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
-rw-r--r-- | resources/libraries/python/TrafficGenerator.py | 13 | ||||
-rwxr-xr-x | resources/tools/t-rex/t-rex-stateless.py | 40 |
2 files changed, 36 insertions, 17 deletions
diff --git a/resources/libraries/python/TrafficGenerator.py b/resources/libraries/python/TrafficGenerator.py index 2a94912860..c28e8ecd10 100644 --- a/resources/libraries/python/TrafficGenerator.py +++ b/resources/libraries/python/TrafficGenerator.py @@ -485,17 +485,8 @@ class TrafficGenerator(object): self._loss = self._result.split(', ')[3].split('=')[1] self._latency = [] - 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)) + self._latency.append(self._result.split(', ')[4].split('=')[1]) + self._latency.append(self._result.split(', ')[5].split('=')[1]) def stop_traffic_on_tg(self): """Stop all traffic on TG diff --git a/resources/tools/t-rex/t-rex-stateless.py b/resources/tools/t-rex/t-rex-stateless.py index b23dfa8889..b58a82a232 100755 --- a/resources/tools/t-rex/t-rex-stateless.py +++ b/resources/tools/t-rex/t-rex-stateless.py @@ -315,6 +315,34 @@ def create_streams_v6(traffic_options, frame_size=78): return create_streams_v46(base_pkt_a, base_pkt_b, vm1, vm2, frame_size) +def fmt_latency(lat_min, lat_avg, lat_max): + """ Return formatted, rounded latency + + :param lat_min: Min latency + :param lat_avg: Average latency + :param lat_max: Max latency + :type lat_min: string + :type lat_avg: string + :type lat_max: string + :return: Formatted and rounded output "min/avg/max" + :rtype: string + """ + + try: + t_min = int(round(float(lat_min))) + except ValueError: + t_min = int(-1) + try: + t_avg = int(round(float(lat_avg))) + except ValueError: + t_avg = int(-1) + try: + t_max = int(round(float(lat_max))) + except ValueError: + t_max = int(-1) + + return "/".join(str(tmp) for tmp in (t_min, t_avg, t_max)) + def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate, warmup_time, async_start, latency): """Run the traffic with specific parameters. @@ -347,8 +375,8 @@ def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate, total_sent = 0 lost_a = 0 lost_b = 0 - lat_a = "0/0/0" - lat_b = "0/0/0" + lat_a = "-1/-1/-1" + lat_b = "-1/-1/-1" try: # turn this off if too many logs @@ -420,14 +448,14 @@ def simple_burst(stream_a, stream_b, stream_lat_a, stream_lat_b, duration, rate, lost_b = stats[1]["opackets"] - stats[0]["ipackets"] if latency: - lat_a = "/".join((\ + lat_a = fmt_latency(\ str(stats["latency"][0]["latency"]["total_min"]),\ str(stats["latency"][0]["latency"]["average"]),\ - str(stats["latency"][0]["latency"]["total_max"]))) - lat_b = "/".join((\ + str(stats["latency"][0]["latency"]["total_max"])) + lat_b = fmt_latency(\ str(stats["latency"][1]["latency"]["total_min"]),\ str(stats["latency"][1]["latency"]["average"]),\ - str(stats["latency"][1]["latency"]["total_max"]))) + str(stats["latency"][1]["latency"]["total_max"])) total_sent = stats[0]["opackets"] + stats[1]["opackets"] total_rcvd = stats[0]["ipackets"] + stats[1]["ipackets"] |