Commit b05f8ae6 authored by cedgar's avatar cedgar
Browse files

improved some warning message, performance does not crash if no traffic found

parent 19c671dd
......@@ -83,10 +83,12 @@ class Performance(object):
self._count_points()
weighted_performance = 0
for traffic_type, packets in self._traffic_counts.items():
# type weighted performance
_performance = (packets["pkts_out"]/packets["pkts_in"]) * (traffic_weights[traffic_type])/(sum(traffic_weights.values()))
if packets["pkts_in"] == 0:
_performance = 0
else:
_performance = (packets["pkts_out"]/packets["pkts_in"]) * (traffic_weights[traffic_type])/(sum(traffic_weights.values()))
weighted_performance += _performance
return weighted_performance
......@@ -100,8 +102,13 @@ class Performance(object):
weighted_performance = self.get_weighted_perfomance()
for traffic_type, traffic_name in traffic_names.items():
packets = self._traffic_counts[traffic_type]
_performance = (packets["pkts_out"]/packets["pkts_in"])
print("{:10} {:.5f}".format(traffic_names[traffic_type], _performance))
warning = ""
if packets["pkts_in"] == 0:
_performance = 0
warning = "\033[31m(warning: you did not send traffic for this type)\033[39m"
else:
_performance = (packets["pkts_out"]/packets["pkts_in"])
print("{:10} {:.5f} {}".format(traffic_names[traffic_type], _performance, warning))
print("-------------------------------")
print("Weighted {:.5f}".format(weighted_performance))
......
......@@ -36,10 +36,10 @@ class Scheduler(object):
start_time = float(kwargs['start_time'])
if time.time() > start_time:
# Note: Do not raise to avoid stacktrace etc.
print("Invalid start time in the past")
print("\033[31mWarning: Invalid start time in the past. This flow won't start. Rerun the experiment\033[31m")
sys.exit(1)
return
# wait before starting
time.sleep(start_time - time.time())
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment