mirror of
https://github.com/verigak/progress.git
synced 2025-12-10 12:15:34 +00:00
prevents I/O from dominating computation time when using progress
This commit is contained in:
@@ -66,18 +66,20 @@ class Infinite(object):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
def next(self, n=1):
|
def next(self, n=1):
|
||||||
if n > 0:
|
if n <= 0:
|
||||||
now = time()
|
return
|
||||||
dt = now - self._ts
|
now = time()
|
||||||
if dt < self.time_threshold:
|
dt = now - self._ts
|
||||||
self._pending += n
|
if dt < self.time_threshold:
|
||||||
else:
|
self._pending += n
|
||||||
self._xput.append((n + self._pending) / dt)
|
else:
|
||||||
self._ts = now
|
# avoid performing computationally intensive update task
|
||||||
self._pending = 0
|
# 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.index = self.index + n
|
||||||
self.update()
|
|
||||||
|
|
||||||
def iter(self, it):
|
def iter(self, it):
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user