Skip to content
Snippets Groups Projects
Unverified Commit a135f810 authored by Simon Désaulniers's avatar Simon Désaulniers
Browse files

benchmark: create function for displaying plot

parent 2da48557
No related branches found
No related tags found
No related merge requests found
...@@ -70,6 +70,21 @@ def display_plot(yvals, xvals=None, yformatter=None, display_time=3, **kwargs): ...@@ -70,6 +70,21 @@ def display_plot(yvals, xvals=None, yformatter=None, display_time=3, **kwargs):
plt.plot(yvals, **kwargs) plt.plot(yvals, **kwargs)
plt.pause(display_time) plt.pause(display_time)
def display_traffic_plot(ifname):
"""Displays the traffic plot for a given interface name.
@param ifname: Interface name.
@type ifname: string
"""
ydata = []
xdata = []
# warning: infinite loop
interval = 2
for rate in iftop_traffic_data(ifname, interval=interval):
ydata.append(rate)
xdata.append((xdata[-1] if len(xdata) > 0 else 0) + interval)
display_plot(ydata, xvals=xdata, yformatter=Kbit_format, color='blue')
def iftop_traffic_data(ifname, interval=2, rate_type='send_receive'): def iftop_traffic_data(ifname, interval=2, rate_type='send_receive'):
""" """
Generator (yields data) function collecting traffic data from iftop Generator (yields data) function collecting traffic data from iftop
...@@ -367,6 +382,7 @@ class PersistenceTest(DhtFeatureTest): ...@@ -367,6 +382,7 @@ class PersistenceTest(DhtFeatureTest):
# initial set of values # initial set of values
i = 0 i = 0
for h in hashes: for h in hashes:
# TODO: bloque dans le put??
self._dhtPut(bootstrap.front(), h, *[Value(v) for v in values]) self._dhtPut(bootstrap.front(), h, *[Value(v) for v in values])
print("at: ", i) print("at: ", i)
i += 1 i += 1
...@@ -410,14 +426,7 @@ class PersistenceTest(DhtFeatureTest): ...@@ -410,14 +426,7 @@ class PersistenceTest(DhtFeatureTest):
self._trigger_dp(trigger_nodes, h) self._trigger_dp(trigger_nodes, h)
if self._traffic_plot: if self._traffic_plot:
ydata = [] display_traffic_plot('br'+wb.ifname)
xdata = []
# warning: infinite loop
interval = 2
for rate in iftop_traffic_data("br"+wb.ifname, interval=interval):
ydata.append(rate)
xdata.append((xdata[-1] if len(xdata) > 0 else 0) + interval)
display_plot(ydata, xvals=xdata, yformatter=Kbit_format, color='blue')
else: else:
# blocks in matplotlib thread # blocks in matplotlib thread
while True: while True:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment