Skip to content
Snippets Groups Projects
Commit 0c686bd6 authored by Adrien Béraud's avatar Adrien Béraud
Browse files

python tools: adapt to latest cython API changes

parent d2be36b6
No related branches found
No related tags found
No related merge requests found
......@@ -47,14 +47,20 @@ def getsTimesTest():
plt.ion()
lines = plt.plot([])
plt.ylabel('time (s)')
#plt.show()
fig, axes = plt.subplots(2, 1)
fig.tight_layout()
lax = axes[0]
hax = axes[1]
lines = None#ax.plot([])
#plt.ylabel('time (s)')
hax.set_ylim(0, 2)
# let the network stabilise
plt.pause(5)
plt.pause(60)
start = time.time()
#start = time.time()
times = []
done = 0
......@@ -83,6 +89,12 @@ def getsTimesTest():
lines = plt.plot(times, color='blue')
plt.draw()
def run_get():
nonlocal done
done += 1
start = time.time()
bootstrap.front().get(InfoHash.getRandom(), getcb, lambda ok, nodes: donecb(ok, nodes, start))
plt.pause(5)
plt.show()
......@@ -101,6 +113,7 @@ def getsTimesTest():
while done > 0:
lock.wait()
update_plot()
update_plot()
print("Took", np.sum(times), "mean", np.mean(times), "std", np.std(times), "min", np.min(times), "max", np.max(times))
print('GET calls timings benchmark test : DONE. ' \
......@@ -143,7 +156,7 @@ if __name__ == '__main__':
output, err = p.communicate()
print(output.decode())
bootstrap = DhtNetwork(iface='br'+args.ifname, first_bootstrap=False if args.bootstrap else True, bootstrap=[(args.bootstrap, "5000")])
bootstrap = DhtNetwork(iface='br'+args.ifname, first_bootstrap=False if args.bootstrap else True, bootstrap=[(args.bootstrap, "5000")] if args.bootstrap else [])
bootstrap.resize(1)
procs = [None for _ in range(clusters)]
......
......@@ -14,9 +14,9 @@ class DhtNetwork(object):
@staticmethod
def run_node(ip4, ip6, p, bootstrap=[], is_bootstrap=False):
print("run_node", ip4, ip6, p, bootstrap)
id = PyIdentity()
#id.generate("dhtbench"+str(p), PyIdentity(), 1024)
n = PyDhtRunner()
id = Identity()
#id.generate("dhtbench"+str(p), Identity(), 1024)
n = DhtRunner()
n.run(id, ipv4=ip4 if ip4 else "", ipv6=ip6 if ip6 else "", port=p, is_bootstrap=is_bootstrap)
for b in bootstrap:
n.bootstrap(b[0], b[1])
......
......@@ -38,7 +38,7 @@ from mpl_toolkits.basemap import Basemap
import GeoIP
done = 0
all_nodes = PyNodeSet()
all_nodes = NodeSet()
plt.ion()
plt.figaspect(2.)
......@@ -76,8 +76,8 @@ gi6 = GeoIP.open("GeoLiteCityv6.dat", GeoIP.GEOIP_INDEX_CACHE | GeoIP.GEOIP_CHEC
def gcb(v):
return True
r = PyDhtRunner()
i = PyIdentity()
r = DhtRunner()
i = Identity()
i.generate(bits = 1024)
r.run(i, port=4112)
......@@ -105,13 +105,13 @@ def nextstep(cur_h, cur_depth, ok, nodes, arc=None, lines=[]):
del arc
for l in lines:
l.set_color('#444444')
snodes = PyNodeSet()
snodes = NodeSet()
snodes.extend(nodes)
all_nodes.extend(nodes)
depth = min(6, PyInfoHash.commonBits(snodes.first(), snodes.last())+4)
depth = min(6, InfoHash.commonBits(snodes.first(), snodes.last())+4)
if cur_depth < depth:
for b in range(cur_depth, depth):
new_h = PyInfoHash(cur_h.toString());
new_h = InfoHash(cur_h.toString());
new_h.setBit(b, 1);
step(new_h, b+1);
done -= 1
......@@ -138,7 +138,7 @@ def restart(arg):
points = []
print(arg)
start_h = PyInfoHash()
start_h = InfoHash()
start_h.setBit(159, 1)
step(start_h, 0)
plt.draw()
......@@ -209,7 +209,7 @@ def update_plot():
if run:
# start first step
start_h = PyInfoHash()
start_h = InfoHash()
start_h.setBit(159, 1)
step(start_h, 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment