~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: Robey Pointer
  • Date: 2006-07-01 19:03:33 UTC
  • mfrom: (1829 +trunk)
  • mto: This revision was merged to the branch mainline in revision 1830.
  • Revision ID: robey@lag.net-20060701190333-f58465aec4bd3412
merge from bzr.dev

Show diffs side-by-side

added added

removed removed

Lines of Context:
137
137
                 to_file=None,
138
138
                 show_pct=False,
139
139
                 show_spinner=False,
140
 
                 show_eta=True,
 
140
                 show_eta=False,
141
141
                 show_bar=True,
142
142
                 show_count=True,
143
143
                 to_messages_file=None,
262
262
        _BaseProgressBar.__init__(self, **kwargs)
263
263
        self.spin_pos = 0
264
264
        self.width = terminal_width()
265
 
        self.start_time = None
266
265
        self.last_updates = deque()
267
266
        self.child_fraction = 0
268
267
    
269
268
 
270
 
    def throttle(self):
 
269
    def throttle(self, old_msg):
271
270
        """Return True if the bar was updated too recently"""
272
271
        # time.time consistently takes 40/4000 ms = 0.01 ms.
273
272
        # but every single update to the pb invokes it.
274
273
        # so we use time.clock which takes 20/4000 ms = 0.005ms
275
274
        # on the downside, time.clock() appears to have approximately
276
275
        # 10ms granularity, so we treat a zero-time change as 'throttled.'
277
 
        
278
276
        now = time.clock()
 
277
        if self.start_time is not None and (now - self.start_time) < 1:
 
278
            return True
 
279
        if old_msg != self.last_msg:
 
280
            return False
279
281
        interval = now - self.last_update
280
282
        # if interval > 0
281
283
        if interval < self.MIN_PAUSE:
341
343
        # but multiple that by 4000 calls -> starts to cost.
342
344
        # so anything to make this function call faster
343
345
        # will improve base 'diff' time by up to 0.1 seconds.
344
 
        if old_msg == self.last_msg and self.throttle():
 
346
        if self.throttle(old_msg):
345
347
            return
346
348
 
347
349
        if self.show_eta and self.start_time and self.last_total: