from foolscap import Referenceable
from allmydata.interfaces import RIControlClient
from allmydata.util import testutil, fileutil, mathutil
+from allmydata import upload, download
from twisted.python import log
def get_memory_usage():
d.addCallback(lambda res: filename)
return d
- def remote_speed_test(self, count, size):
+ def remote_speed_test(self, count, size, mutable):
assert size > 8
- log.msg("speed_test: count=%d, size=%d" % (count, size))
- st = SpeedTest(self.parent, count, size)
+ log.msg("speed_test: count=%d, size=%d, mutable=%d" % (count, size,
+ mutable))
+ st = SpeedTest(self.parent, count, size, mutable)
return st.run()
def remote_get_memory_usage(self):
return d
class SpeedTest:
- def __init__(self, parent, count, size):
+ def __init__(self, parent, count, size, mutable):
self.parent = parent
self.count = count
self.size = size
+ self.mutable = mutable
self.uris = {}
self.basedir = os.path.join(self.parent.basedir, "_speed_test_data")
f.close()
def do_upload(self):
- uploader = self.parent.getServiceNamed("uploader")
start = time.time()
d = defer.succeed(None)
def _record_uri(uri, i):
if i >= self.count:
return
fn = os.path.join(self.basedir, str(i))
- d1 = uploader.upload_filename(fn)
+ if self.mutable:
+ data = open(fn,"rb").read()
+ d1 = self.parent.create_mutable_file(data)
+ d1.addCallback(lambda n: n.get_uri())
+ else:
+ up = upload.FileName(fn)
+ d1 = self.parent.upload(up)
d1.addCallback(_record_uri, i)
d1.addCallback(_upload_one_file, i+1)
return d1
return d
def do_download(self):
- downloader = self.parent.getServiceNamed("downloader")
start = time.time()
d = defer.succeed(None)
def _download_one_file(ignored, i):
if i >= self.count:
return
- d1 = downloader.download_to_filehandle(self.uris[i], Discard())
+ n = self.parent.create_node_from_uri(self.uris[i])
+ d1 = n.download(download.FileHandle(Discard()))
d1.addCallback(_download_one_file, i+1)
return d1
d.addCallback(_download_one_file, 0)
print "TIME (%s): %s up, %s down" % (key, times[0], times[1])
self.upload_times[key], self.download_times[key] = times
- def one_test(self, res, name, count, size):
- d = self.client_rref.callRemote("speed_test", count, size)
+ def one_test(self, res, name, count, size, mutable):
+ d = self.client_rref.callRemote("speed_test", count, size, mutable)
d.addCallback(self.record_times, name)
return d
print "doing test"
rr = self.client_rref
d = defer.succeed(None)
- d.addCallback(self.one_test, "startup", 1, 1000) # ignore this one
+ d.addCallback(self.one_test, "startup", 1, 1000, False) #ignore this one
d.addCallback(self.measure_rtt)
- d.addCallback(self.one_test, "1x 200B", 1, 200)
- d.addCallback(self.one_test, "10x 200B", 10, 200)
+ d.addCallback(self.one_test, "1x 200B", 1, 200, False)
+ d.addCallback(self.one_test, "10x 200B", 10, 200, False)
def _maybe_do_100x_200B(res):
if self.upload_times["10x 200B"] < 5:
print "10x 200B test went too fast, doing 100x 200B test"
- return self.one_test(None, "100x 200B", 100, 200)
+ return self.one_test(None, "100x 200B", 100, 200, False)
return
- d.addCallback(_maybe_do_100x_200B)
- d.addCallback(self.one_test, "1MB", 1, 1*MB)
- d.addCallback(self.one_test, "10MB", 1, 10*MB)
+ #d.addCallback(_maybe_do_100x_200B)
+ d.addCallback(self.one_test, "1MB", 1, 1*MB, False)
+ d.addCallback(self.one_test, "10MB", 1, 10*MB, False)
def _maybe_do_100MB(res):
if self.upload_times["10MB"] > 30:
print "10MB test took too long, skipping 100MB test"
return
- return self.one_test(None, "100MB", 1, 100*MB)
- d.addCallback(_maybe_do_100MB)
+ return self.one_test(None, "100MB", 1, 100*MB, False)
+ #d.addCallback(_maybe_do_100MB)
+ d.addCallback(self.one_test, "1x 200B SSK", 1, 200, True)
+ d.addCallback(self.one_test, "10x 200B SSK", 10, 200, True)
+ d.addCallback(self.one_test, "1MB SSK", 1, 1*MB, True)
d.addCallback(self.calculate_speeds)
return d
A3 = 100*MB / (self.download_times["100MB"] - B)
print "download speed (100MB):", self.number(A3, "Bps")
+
+ # upload SSK
+ if "100x 200B SSK" in self.upload_times:
+ B = self.upload_times["100x 200B SSK"] / 100
+ else:
+ B = self.upload_times["10x 200B SSK"] / 10
+ print "upload per-file time SSK: %.3fs" % B
+ A1 = 1*MB / (self.upload_times["1MB SSK"] - B) # in bytes per second
+ print "upload speed SSK (1MB):", self.number(A1, "Bps")
+
+ # download SSK
+ if "100x 200B SSK" in self.download_times:
+ B = self.download_times["100x 200B SSK"] / 100
+ else:
+ B = self.download_times["10x 200B SSK"] / 10
+ print "download per-file time SSK: %.3fs" % B
+ A1 = 1*MB / (self.download_times["1MB SSK"] - B) # in bytes per second
+ print "download speed SSK (1MB):", self.number(A1, "Bps")
+
def number(self, value, suffix=""):
scaling = 1
if value < 1: