Speed and memory improvement for populating StringIO

This commit is contained in:
Matt Martz 2014-04-12 22:58:57 -04:00
parent 6888a5aae1
commit dfeb19ff68
1 changed files with 5 additions and 5 deletions

View File

@ -294,11 +294,9 @@ class HTTPUploaderData(object):
self.timeout = timeout
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
data = chars * (int(round(int(length) / 36.0)))
self.data = StringIO()
self.data.write('content1=%s' % data[0:int(length) - 9])
del data
self.data.seek(0)
multiplier = int(round(int(length) / 36.0))
self.data = StringIO('content1=%s' %
(chars * multiplier)[0:int(length) - 9])
self.total = [0]
@ -341,6 +339,8 @@ class HTTPUploader(threading.Thread):
except:
self.result = sum(self.data.total)
del self.data
class SpeedtestResults(object):
"""Class for holding the results of a speedtest, including: