##// END OF EJS Templates
progress: make ETA only consider progress made in the last minute...
Jun Wu -
r34315:a667f0ca default
parent child Browse files
Show More
@@ -359,6 +359,9 b" coreconfigitem('progress', 'delay',"
359 coreconfigitem('progress', 'disable',
359 coreconfigitem('progress', 'disable',
360 default=False,
360 default=False,
361 )
361 )
362 coreconfigitem('progress', 'estimateinterval',
363 default=60.0,
364 )
362 coreconfigitem('progress', 'refresh',
365 coreconfigitem('progress', 'refresh',
363 default=0.1,
366 default=0.1,
364 )
367 )
@@ -1613,6 +1613,10 b' have a definite end point.'
1613 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1613 Minimum delay before showing a new topic. When set to less than 3 * refresh,
1614 that value will be used instead. (default: 1)
1614 that value will be used instead. (default: 1)
1615
1615
1616 ``estimateinterval``
1617 Maximum sampling interval in seconds for speed and estimated time
1618 calculation. (default: 60)
1619
1616 ``refresh``
1620 ``refresh``
1617 Time in seconds between refreshes of the progress bar. (default: 0.1)
1621 Time in seconds between refreshes of the progress bar. (default: 0.1)
1618
1622
@@ -104,6 +104,8 b' class progbar(object):'
104 self.order = self.ui.configlist(
104 self.order = self.ui.configlist(
105 'progress', 'format',
105 'progress', 'format',
106 default=['topic', 'bar', 'number', 'estimate'])
106 default=['topic', 'bar', 'number', 'estimate'])
107 self.estimateinterval = self.ui.configwith(
108 float, 'progress', 'estimateinterval')
107
109
108 def show(self, now, topic, pos, item, unit, total):
110 def show(self, now, topic, pos, item, unit, total):
109 if not shouldprint(self.ui):
111 if not shouldprint(self.ui):
@@ -238,6 +240,32 b' class progbar(object):'
238 else:
240 else:
239 return False
241 return False
240
242
243 def _calibrateestimate(self, topic, now, pos):
244 '''Adjust starttimes and startvals for topic so ETA works better
245
246 If progress is non-linear (ex. get much slower in the last minute),
247 it's more friendly to only use a recent time span for ETA and speed
248 calculation.
249
250 [======================================> ]
251 ^^^^^^^
252 estimateinterval, only use this for estimation
253 '''
254 interval = self.estimateinterval
255 if interval <= 0:
256 return
257 elapsed = now - self.starttimes[topic]
258 if elapsed > interval:
259 delta = pos - self.startvals[topic]
260 newdelta = delta * interval / elapsed
261 # If a stall happens temporarily, ETA could change dramatically
262 # frequently. This is to avoid such dramatical change and make ETA
263 # smoother.
264 if newdelta < 0.1:
265 return
266 self.startvals[topic] = pos - newdelta
267 self.starttimes[topic] = now - interval
268
241 def progress(self, topic, pos, item='', unit='', total=None):
269 def progress(self, topic, pos, item='', unit='', total=None):
242 now = time.time()
270 now = time.time()
243 self._refreshlock.acquire()
271 self._refreshlock.acquire()
@@ -268,6 +296,7 b' class progbar(object):'
268 self.topics.append(topic)
296 self.topics.append(topic)
269 self.topicstates[topic] = pos, item, unit, total
297 self.topicstates[topic] = pos, item, unit, total
270 self.curtopic = topic
298 self.curtopic = topic
299 self._calibrateestimate(topic, now, pos)
271 if now - self.lastprint >= self.refresh and self.topics:
300 if now - self.lastprint >= self.refresh and self.topics:
272 if self._oktoprint(now):
301 if self._oktoprint(now):
273 self.lastprint = now
302 self.lastprint = now
@@ -260,17 +260,17 b' Non-linear progress:'
260 loop [===========> ] 6/20 4m41s\r (no-eol) (esc)
260 loop [===========> ] 6/20 4m41s\r (no-eol) (esc)
261 loop [=============> ] 7/20 4m21s\r (no-eol) (esc)
261 loop [=============> ] 7/20 4m21s\r (no-eol) (esc)
262 loop [===============> ] 8/20 4m01s\r (no-eol) (esc)
262 loop [===============> ] 8/20 4m01s\r (no-eol) (esc)
263 loop [================> ] 9/20 13m27s\r (no-eol) (esc)
263 loop [================> ] 9/20 25m40s\r (no-eol) (esc)
264 loop [==================> ] 10/20 19m21s\r (no-eol) (esc)
264 loop [===================> ] 10/20 1h06m\r (no-eol) (esc)
265 loop [====================> ] 11/20 22m39s\r (no-eol) (esc)
265 loop [=====================> ] 11/20 1h13m\r (no-eol) (esc)
266 loop [======================> ] 12/20 24m01s\r (no-eol) (esc)
266 loop [=======================> ] 12/20 1h07m\r (no-eol) (esc)
267 loop [========================> ] 13/20 23m53s\r (no-eol) (esc)
267 loop [========================> ] 13/20 58m19s\r (no-eol) (esc)
268 loop [==========================> ] 14/20 19m09s\r (no-eol) (esc)
268 loop [===========================> ] 14/20 7m09s\r (no-eol) (esc)
269 loop [============================> ] 15/20 15m01s\r (no-eol) (esc)
269 loop [=============================> ] 15/20 3m38s\r (no-eol) (esc)
270 loop [==============================> ] 16/20 11m21s\r (no-eol) (esc)
270 loop [===============================> ] 16/20 2m15s\r (no-eol) (esc)
271 loop [=================================> ] 17/20 8m04s\r (no-eol) (esc)
271 loop [=================================> ] 17/20 1m27s\r (no-eol) (esc)
272 loop [===================================> ] 18/20 5m07s\r (no-eol) (esc)
272 loop [====================================> ] 18/20 52s\r (no-eol) (esc)
273 loop [=====================================> ] 19/20 2m27s\r (no-eol) (esc)
273 loop [======================================> ] 19/20 25s\r (no-eol) (esc)
274 \r (no-eol) (esc)
274 \r (no-eol) (esc)
275
275
276 Time estimates should not fail when there's no end point:
276 Time estimates should not fail when there's no end point:
General Comments 0
You need to be logged in to leave comments. Login now