~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/progress.py

  • Committer: John Arbash Meinel
  • Date: 2006-11-03 23:29:49 UTC
  • mto: This revision was merged to the branch mainline in revision 2121.
  • Revision ID: john@arbash-meinel.com-20061103232949-72f71bdbde11ed6b
Use time.time() because time.clock() is CPU time, not wall time

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:
511
508
    if current > total:
512
509
        return None                     # wtf?
513
510
 
514
 
    elapsed = time.clock() - start_time
 
511
    elapsed = time.time() - start_time
515
512
 
516
513
    if elapsed < 2.0:                   # not enough time to estimate
517
514
        return None