check_speed: rearrange a bit to make it easy to disable certain portions
This commit is contained in:
parent
8377244c46
commit
f39f8ae032
|
@ -9,6 +9,10 @@ from foolscap import Tub, eventual
|
|||
MB = 1000000
|
||||
|
||||
class SpeedTest:
|
||||
DO_IMMUTABLE = True
|
||||
DO_MUTABLE_CREATE = True
|
||||
DO_MUTABLE = True
|
||||
|
||||
def __init__(self, test_client_dir):
|
||||
#self.real_stderr = sys.stderr
|
||||
log.startLogging(open("st.log", "a"), setStdout=False)
|
||||
|
@ -95,6 +99,7 @@ class SpeedTest:
|
|||
d.addCallback(self.one_test, "startup", 1, 1000, False) #ignore this one
|
||||
d.addCallback(self.measure_rtt)
|
||||
|
||||
if self.DO_IMMUTABLE:
|
||||
# immutable files
|
||||
d.addCallback(self.one_test, "1x 200B", 1, 200, False)
|
||||
d.addCallback(self.one_test, "10x 200B", 10, 200, False)
|
||||
|
@ -113,18 +118,23 @@ class SpeedTest:
|
|||
return self.one_test(None, "100MB", 1, 100*MB, False)
|
||||
d.addCallback(_maybe_do_100MB)
|
||||
|
||||
if self.DO_MUTABLE_CREATE:
|
||||
# mutable file creation
|
||||
d.addCallback(self.one_test, "10x 200B SSK creation", 10, 200, "create")
|
||||
d.addCallback(self.one_test, "10x 200B SSK creation", 10, 200,
|
||||
"create")
|
||||
|
||||
if self.DO_MUTABLE:
|
||||
# mutable file upload/download
|
||||
d.addCallback(self.one_test, "10x 200B SSK", 10, 200, "upload")
|
||||
def _maybe_do_100x_200B_SSK(res):
|
||||
if self.upload_times["10x 200B SSK"] < 5:
|
||||
print "10x 200B SSK test went too fast, doing 100x 200B SSK"
|
||||
return self.one_test(None, "100x 200B SSK", 100, 200, "upload")
|
||||
return self.one_test(None, "100x 200B SSK", 100, 200,
|
||||
"upload")
|
||||
return
|
||||
d.addCallback(_maybe_do_100x_200B_SSK)
|
||||
d.addCallback(self.one_test, "1MB SSK", 1, 1*MB, "upload")
|
||||
|
||||
d.addCallback(self.calculate_speeds)
|
||||
return d
|
||||
|
||||
|
@ -132,6 +142,7 @@ class SpeedTest:
|
|||
# time = A*size+B
|
||||
# we assume that A*200bytes is negligible
|
||||
|
||||
if self.DO_IMMUTABLE:
|
||||
# upload
|
||||
if "100x 200B" in self.upload_times:
|
||||
B = self.upload_times["100x 200B"] / 100
|
||||
|
@ -164,10 +175,12 @@ class SpeedTest:
|
|||
A3 = 100*MB / (self.download_times["100MB"] - B)
|
||||
print "download speed (100MB):", self.number(A3, "Bps")
|
||||
|
||||
if self.DO_MUTABLE_CREATE:
|
||||
# SSK creation
|
||||
B = self.upload_times["10x 200B SSK creation"] / 10
|
||||
print "create per-file time SSK: %.3fs" % B
|
||||
|
||||
if self.DO_MUTABLE:
|
||||
# upload SSK
|
||||
if "100x 200B SSK" in self.upload_times:
|
||||
B = self.upload_times["100x 200B SSK"] / 100
|
||||
|
@ -183,7 +196,8 @@ class SpeedTest:
|
|||
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
|
||||
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=""):
|
||||
|
|
Loading…
Reference in New Issue