summaryrefslogtreecommitdiffstats
path: root/module/network/HTTPDownload.py
diff options
context:
space:
mode:
authorGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-14 21:48:48 +0100
committerGravatar RaNaN <Mast3rRaNaN@hotmail.de> 2011-02-14 21:48:48 +0100
commitdc99fe918b035b3a049493e945d837077f79aac8 (patch)
treeaeaa5f3cdd45c26f93fd75b54658bb7c81d63ee7 /module/network/HTTPDownload.py
parentgui DownloadInfo fix (diff)
downloadpyload-dc99fe918b035b3a049493e945d837077f79aac8.tar.xz
averaged download speed
Diffstat (limited to 'module/network/HTTPDownload.py')
-rw-r--r--module/network/HTTPDownload.py14
1 files changed, 5 insertions, 9 deletions
diff --git a/module/network/HTTPDownload.py b/module/network/HTTPDownload.py
index 394d759dc..4c9d0705d 100644
--- a/module/network/HTTPDownload.py
+++ b/module/network/HTTPDownload.py
@@ -65,12 +65,14 @@ class HTTPDownload():
self.lastChecked = 0
self.lastArrived = []
self.speeds = []
+ self.lastSpeeds = [0, 0]
self.progressNotify = progressNotify
@property
def speed(self):
- return sum(self.speeds)
+ last = [sum(x) for x in self.lastSpeeds if x]
+ return (sum(self.speeds) + sum(last)) / (1 + len(last))
@property
def arrived(self):
@@ -197,18 +199,12 @@ class HTTPDownload():
diff = [c.arrived - (self.lastArrived[i] if len(self.lastArrived) > i else 0) for i, c in
enumerate(self.chunks)]
- #for i, c in enumerate(self.chunks):
- # diff[i] = c.arrived - (self.lastArrived[i] if len(self.lastArrived) > i else 0)
-
+ self.lastSpeeds[1] = self.lastSpeeds[0]
+ self.lastSpeeds[0] = self.speeds
self.speeds = [float(a) / (t - self.lastChecked) for a in diff]
self.lastArrived = [c.arrived for c in self.chunks]
self.lastChecked = t
self.updateProgress()
- #print "------------------------"
- #print self.speed / 1024, "kb/s"
- #print "Arrived:", self.arrived
- #print "Size:", self.size
- #print self.percent, "%"
if self.abort:
raise Abort()