+import os, time
from zope.interface import implements
from twisted.application import service
from foolscap import Referenceable
from allmydata.interfaces import RIControlClient
-from allmydata.util import testutil
+from allmydata.util import testutil, idlib
from twisted.python import log
def get_memory_usage():
d.addCallback(lambda res: filename)
return d
+ def remote_upload_speed_test(self, size):
+ """Write a tempfile to disk of the given size. Measure how long
+ it takes to upload it to the servers.
+ """
+ assert size > 8
+ fn = os.path.join(self.parent.basedir, idlib.b2a(os.urandom(8)))
+ f = open(fn, "w")
+ f.write(os.urandom(8))
+ size -= 8
+ while size > 0:
+ chunk = min(size, 4096)
+ f.write("\x00" * chunk)
+ size -= chunk
+ f.close()
+ uploader = self.parent.getServiceNamed("uploader")
+ start = time.time()
+ d = uploader.upload_filename(fn)
+ def _done(uri):
+ stop = time.time()
+ return stop - start
+ d.addCallback(_done)
+ def _cleanup(res):
+ os.unlink(fn)
+ return res
+ d.addBoth(_cleanup)
+ return d
+
def remote_get_memory_usage(self):
return get_memory_usage()
keys are 'VmPeak', 'VmSize', and 'VmData'. The values are integers,
measuring memory consupmtion in bytes."""
return DictOf(str, int)
+
+ def upload_speed_test(size=int):
+ """Write a tempfile to disk of the given size. Measure how long
+ it takes to upload it to the servers.
+ """
+ return float
f.close()
self.base_service = service.MultiService()
self.failed = None
+ self.times = {}
def run(self):
print "STARTING"
reactor.callLater(delay, d.callback, result)
return d
+ def record_time(self, time, key):
+ print "TIME (%s): %s" % (key, time)
+ self.times[key] = time
+
def do_test(self):
print "doing test"
- d = self.client_rref.callRemote("get_memory_usage")
+ rr = self.client_rref
+ d = rr.callRemote("get_memory_usage")
def _got(res):
print "MEMORY USAGE:", res
d.addCallback(_got)
+ d.addCallback(lambda res: rr.callRemote("upload_speed_test", 1000))
+ d.addCallback(self.record_time, "startup")
+ d.addCallback(lambda res: rr.callRemote("upload_speed_test", int(1e6)))
+ d.addCallback(self.record_time, "1MB.1")
+ d.addCallback(lambda res: rr.callRemote("upload_speed_test", int(1e6)))
+ d.addCallback(self.record_time, "1MB.2")
return d
def tearDown(self, res):