mirror of
https://github.com/verigak/progress.git
synced 2025-12-08 19:33:24 +00:00
Merge pull request #32 from aduriseti/master
Reduce I/O Cost - no change to ETA algorithm
This commit is contained in:
@@ -66,18 +66,20 @@ class Infinite(object):
|
||||
pass
|
||||
|
||||
def next(self, n=1):
|
||||
if n > 0:
|
||||
now = time()
|
||||
dt = now - self._ts
|
||||
if dt < self.time_threshold:
|
||||
self._pending += n
|
||||
else:
|
||||
self._xput.append((n + self._pending) / dt)
|
||||
self._ts = now
|
||||
self._pending = 0
|
||||
|
||||
if n <= 0:
|
||||
return
|
||||
now = time()
|
||||
dt = now - self._ts
|
||||
if dt < self.time_threshold:
|
||||
self._pending += n
|
||||
else:
|
||||
# avoid performing computationally intensive update task
|
||||
# more than 1/dt (10 by default) times a second
|
||||
self._xput.append((self._pending + n) / dt)
|
||||
self._ts = now
|
||||
self._pending = 0
|
||||
self.update()
|
||||
self.index = self.index + n
|
||||
self.update()
|
||||
|
||||
def iter(self, it):
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user