aboutsummaryrefslogtreecommitdiffstats
path: root/resources/tools/t-rex
diff options
context:
space:
mode:
authorMiroslav Miklus <mmiklus@cisco.com>2016-09-20 16:43:19 +0200
committerPeter Mikus <pmikus@cisco.com>2016-09-24 02:36:24 +0000
commit030f0dff4adbb5da9be2a18cbafec9b077a6723f (patch)
tree79294b062c3aafb28d2c80e9e601c718992bd4aa /resources/tools/t-rex
parent5890588ad2d15c82ca49e0fcf6b2944c71c48501 (diff)
CSIT-412 replace latency (N/A) string by number -1
Change-Id: Id6373d3bbfcc42e315976b59aa86c6cadee411f1 Signed-off-by: Miroslav Miklus <mmiklus@cisco.com>
Diffstat (limited to 'resources/tools/t-rex')
-rwxr-xr-xresources/tools/t-rex/t-rex-stateless.py40
1 files changed, 34 insertions, 6 deletions
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"]