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
|
self.timeout = timeout
|
||||||
|
|
||||||
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
|
||||||
data = chars * (int(round(int(length) / 36.0)))
|
multiplier = int(round(int(length) / 36.0))
|
||||||
self.data = StringIO()
|
self.data = StringIO('content1=%s' %
|
||||||
self.data.write('content1=%s' % data[0:int(length) - 9])
|
(chars * multiplier)[0:int(length) - 9])
|
||||||
del data
|
|
||||||
self.data.seek(0)
|
|
||||||
|
|
||||||
self.total = [0]
|
self.total = [0]
|
||||||
|
|
||||||
|
@ -341,6 +339,8 @@ class HTTPUploader(threading.Thread):
|
||||||
except:
|
except:
|
||||||
self.result = sum(self.data.total)
|
self.result = sum(self.data.total)
|
||||||
|
|
||||||
|
del self.data
|
||||||
|
|
||||||
|
|
||||||
class SpeedtestResults(object):
|
class SpeedtestResults(object):
|
||||||
"""Class for holding the results of a speedtest, including:
|
"""Class for holding the results of a speedtest, including:
|
||||||
|
|
Loading…
Reference in New Issue