summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--yardstick/benchmark/scenarios/networking/netutilization.py29
1 files changed, 14 insertions, 15 deletions
diff --git a/yardstick/benchmark/scenarios/networking/netutilization.py b/yardstick/benchmark/scenarios/networking/netutilization.py
index 1ba6f1ec3..37da7f895 100644
--- a/yardstick/benchmark/scenarios/networking/netutilization.py
+++ b/yardstick/benchmark/scenarios/networking/netutilization.py
@@ -100,30 +100,22 @@ class NetUtilization(base.Scenario):
average = {}
time_marker = re.compile("^([0-9]+):([0-9]+):([0-9]+)$")
- ampm_marker = re.compile("(AM|PM)$")
# Parse network utilization stats
- for row in raw_result.split('\n'):
+ for row in raw_result.splitlines():
line = row.split()
if line and re.match(time_marker, line[0]):
- if re.match(ampm_marker, line[1]):
- del line[:2]
- if line[0] == 'IFACE':
- # header fields
- fields = line[1:]
- if len(fields) != NetUtilization.\
- NET_UTILIZATION_FIELD_SIZE:
- raise RuntimeError("network_utilization: unexpected\
- field size", fields)
- else:
- # value fields
+ try:
+ index = line.index('IFACE')
+ except ValueError:
+ del line[:index]
net_interface = line[0]
values = line[1:]
if values and len(values) == len(fields):
- temp_dict = dict(list(zip(fields, values)))
+ temp_dict = dict(zip(fields, values))
if net_interface not in maximum:
maximum[net_interface] = temp_dict
else:
@@ -144,6 +136,13 @@ class NetUtilization(base.Scenario):
else:
raise RuntimeError("network_utilization: parse error",
fields, line)
+ else:
+ del line[:index]
+ fields = line[1:]
+ if len(fields) != NetUtilization.\
+ NET_UTILIZATION_FIELD_SIZE:
+ raise RuntimeError("network_utilization: unexpected\
+ field size", fields)
elif line and line[0] == 'Average:':
del line[:1]
@@ -161,7 +160,7 @@ class NetUtilization(base.Scenario):
values = line[1:]
if values and len(values) == len(fields):
average[net_interface] = dict(
- list(zip(fields, values)))
+ zip(fields, values))
else:
raise RuntimeError("network_utilization average: \
parse error", fields, line)