def remote_get_memory_usage(self):
return get_memory_usage()
+ def remote_measure_peer_response_time(self):
+ results = {}
+ everyone = list(self.parent.introducer_client.get_all_peers())
+ d = self._do_one_ping(None, everyone, results)
+ return d
+ def _do_one_ping(self, res, everyone_left, results):
+ if not everyone_left:
+ return results
+ peerid, connection = everyone_left.pop(0)
+ start = time.time()
+ d = connection.callRemote("get_nodeid")
+ def _done(ignored):
+ stop = time.time()
+ results[peerid] = stop - start
+ d.addCallback(_done)
+ d.addCallback(self._do_one_ping, everyone_left, results)
+ return d
+
class SpeedTest:
def __init__(self, parent, count, size):
self.parent = parent
Returns a tuple of (upload_time, download_time).
"""
return (float, float)
+
+ def measure_peer_response_time():
+ """Send a short message to each connected peer, and measure the time
+ it takes for them to respond to it. This is a rough measure of the
+ application-level round trip time.
+
+ @return: a dictionary mapping peerid to a float (RTT time in seconds)
+ """
+
+ return DictOf(Nodeid, float)
d.addCallback(lambda res: rref.callRemote("speed_test", 1, 200))
if sys.platform == "linux2":
d.addCallback(lambda res: rref.callRemote("get_memory_usage"))
+ d.addCallback(lambda res: rref.callRemote("measure_peer_response_time"))
return d