diff --git a/python/tools/benchmark.py b/python/tools/benchmark.py index bf718a53b03a68586734a525a807a59e20c5a675..c5461ddf5227ef8c223f313d37ce557c09b46a11 100755 --- a/python/tools/benchmark.py +++ b/python/tools/benchmark.py @@ -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() @@ -100,6 +112,7 @@ def getsTimesTest(): bootstrap.front().get(PyInfoHash.getRandom(), getcb, donecb) 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)) @@ -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)] diff --git a/python/tools/dhtnetwork.py b/python/tools/dhtnetwork.py index 56da0895535416116a4c2430f18c19a3be662353..9d78dee8ecce153963ad4763f6e2ec54cf5d07ac 100755 --- a/python/tools/dhtnetwork.py +++ b/python/tools/dhtnetwork.py @@ -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]) diff --git a/python/tools/scanner.py b/python/tools/scanner.py index 439ba7204b8abafeb42f20fba95f2f06bb5b314c..35e3d0847b4bdec25bd38741d4ef219fb9210e24 100755 --- a/python/tools/scanner.py +++ b/python/tools/scanner.py @@ -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)