~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: John Arbash Meinel
  • Date: 2006-12-01 19:41:16 UTC
  • mfrom: (2158 +trunk)
  • mto: This revision was merged to the branch mainline in revision 2159.
  • Revision ID: john@arbash-meinel.com-20061201194116-nvn5qhfxux5284jc
[merge] bzr.dev 2158

Show diffs side-by-side

added added

removed removed

Lines of Context:
179
179
        self._stack = _stack
180
180
        # seed throttler
181
181
        self.MIN_PAUSE = 0.1 # seconds
182
 
        now = time.clock()
 
182
        now = time.time()
183
183
        # starting now
184
184
        self.start_time = now
185
185
        # next update should not throttle
297
297
    def throttle(self, old_msg):
298
298
        """Return True if the bar was updated too recently"""
299
299
        # time.time consistently takes 40/4000 ms = 0.01 ms.
300
 
        # but every single update to the pb invokes it.
301
 
        # so we use time.clock which takes 20/4000 ms = 0.005ms
302
 
        # on the downside, time.clock() appears to have approximately
303
 
        # 10ms granularity, so we treat a zero-time change as 'throttled.'
304
 
        now = time.clock()
 
300
        # time.clock() is faster, but gives us CPU time, not wall-clock time
 
301
        now = time.time()
305
302
        if self.start_time is not None and (now - self.start_time) < 1:
306
303
            return True
307
304
        if old_msg != self.last_msg:
432
429
            bar_str = ''
433
430
 
434
431
        m = spin_str + bar_str + self.last_msg + count_str + pct_str + eta_str
435
 
 
436
 
        assert len(m) < self.width
437
 
        self.to_file.write('\r' + m.ljust(self.width - 1))
 
432
        self.to_file.write('\r%-*.*s' % (self.width - 1, self.width - 1, m))
438
433
        self._have_output = True
439
434
        #self.to_file.flush()
440
435
            
513
508
    if current > total:
514
509
        return None                     # wtf?
515
510
 
516
 
    elapsed = time.clock() - start_time
 
511
    elapsed = time.time() - start_time
517
512
 
518
513
    if elapsed < 2.0:                   # not enough time to estimate
519
514
        return None