~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

Move doctest import to increase speed

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=False,
 
140
                 show_eta=True,
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
265
266
        self.last_updates = deque()
266
267
        self.child_fraction = 0
267
268
    
268
269
 
269
 
    def throttle(self, old_msg):
 
270
    def throttle(self):
270
271
        """Return True if the bar was updated too recently"""
271
272
        # time.time consistently takes 40/4000 ms = 0.01 ms.
272
273
        # but every single update to the pb invokes it.
273
274
        # so we use time.clock which takes 20/4000 ms = 0.005ms
274
275
        # on the downside, time.clock() appears to have approximately
275
276
        # 10ms granularity, so we treat a zero-time change as 'throttled.'
 
277
        
276
278
        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
281
279
        interval = now - self.last_update
282
280
        # if interval > 0
283
281
        if interval < self.MIN_PAUSE:
343
341
        # but multiple that by 4000 calls -> starts to cost.
344
342
        # so anything to make this function call faster
345
343
        # will improve base 'diff' time by up to 0.1 seconds.
346
 
        if self.throttle(old_msg):
 
344
        if old_msg == self.last_msg and self.throttle():
347
345
            return
348
346
 
349
347
        if self.show_eta and self.start_time and self.last_total: