From 4622a82847402176ff3fc7f7c658512d242847bd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com> Date: Sun, 15 May 2016 01:38:33 -0400 Subject: [PATCH] benchmark/get: improve ploting --- python/tools/dht/network.py | 10 ++++------ python/tools/dht/tests.py | 15 +++++++++------ 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/python/tools/dht/network.py b/python/tools/dht/network.py index 533b19ea..0d186c2e 100755 --- a/python/tools/dht/network.py +++ b/python/tools/dht/network.py @@ -273,13 +273,11 @@ class DhtNetwork(object): @staticmethod def run_node(ip4, ip6, p, bootstrap=[], is_bootstrap=False): DhtNetwork.log("run_node", ip4, ip6, p, bootstrap) - 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) + n.run(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]) - #plt.pause(0.02) + time.sleep(.01) return ((ip4, ip6, p), n, id) @staticmethod @@ -387,11 +385,11 @@ class DhtNetwork(object): if n == l: return if n > l: - DhtNetwork.log("Launching", n-l, "nodes") + DhtNetwork.log("Launching", n-l, "nodes", self.ip4, self.ip6) for i in range(l, n): self.launch_node() else: - DhtNetwork.log("Ending", l-n, "nodes") + DhtNetwork.log("Ending", l-n, "nodes", self.ip4, self.ip6) #random.shuffle(self.nodes) for i in range(n, l): self.end_node() diff --git a/python/tools/dht/tests.py b/python/tools/dht/tests.py index b9d7d29d..5c7b99cc 100644 --- a/python/tools/dht/tests.py +++ b/python/tools/dht/tests.py @@ -636,7 +636,7 @@ class PerformanceTest(DhtFeatureTest): hax.set_ylim(0, 2) # let the network stabilise - plt.pause(60) + plt.pause(20) #start = time.time() times = [] @@ -649,7 +649,7 @@ class PerformanceTest(DhtFeatureTest): DhtNetwork.log("found", v) return True - def donecb(ok, nodes): + def donecb(ok, nodes, start): nonlocal bootstrap, lock, done, times t = time.time()-start with lock: @@ -665,7 +665,10 @@ class PerformanceTest(DhtFeatureTest): l = lines.pop() l.remove() del l - lines = plt.plot(times, color='blue') + if len(times) > 1: + n, bins, lines = hax.hist(times, 100, normed=1, histtype='stepfilled', color='g') + hax.set_ylim(min(n), max(n)) + lines.extend(lax.plot(times, color='blue')) plt.draw() def run_get(): @@ -686,12 +689,12 @@ class PerformanceTest(DhtFeatureTest): DhtNetwork.log("Getting 50 random hashes succesively.") for i in range(50): with lock: - done += 1 - start = time.time() - bootstrap.front().get(InfoHash.getRandom(), getcb, donecb) + for _ in range(1): + run_get() while done > 0: lock.wait() update_plot() + plt.pause(.1) update_plot() print("Took", np.sum(times), "mean", np.mean(times), "std", np.std(times), "min", np.min(times), "max", np.max(times)) -- GitLab