Speed and memory improvement for populating StringIO
This commit is contained in:
parent
6888a5aae1
commit
dfeb19ff68
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue