Bug 1543017 - Don't update test progress bar so often r=sfink
authorJon Coppeard <jcoppeard@mozilla.com>
Tue, 09 Apr 2019 09:11:11 +0100
changeset 468823 16070c339499f48ad623688092ae6733663cac22
parent 468822 ced956a624de1e59f318bb124c79417068fecd10
child 468824 0d99df46e4c92268e27439dde4b15902e8a061e6
push id35851
push userdvarga@mozilla.com
push dateWed, 10 Apr 2019 21:56:12 +0000
treeherdermozilla-central@30ca3c3abfe6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssfink
bugs1543017
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1543017 - Don't update test progress bar so often r=sfink Don't update the progress bar more than necessary by recording the last update time and checking in poke(). Network traffic is down to 12KB/s with this patch.
js/src/tests/lib/progressbar.py
--- a/js/src/tests/lib/progressbar.py
+++ b/js/src/tests/lib/progressbar.py
@@ -34,16 +34,18 @@ class ProgressBar(object):
         # [{str:str}] Describtion of how to lay out each field in the counters map.
         self.counters_fmt = fmt
         # int: The value of 'current' equal to 100%.
         self.limit = limit
         # int: max digits in limit
         self.limit_digits = int(math.ceil(math.log10(self.limit)))
         # datetime: The start time.
         self.t0 = datetime.now()
+        # datetime: Optional, the last time update() ran.
+        self.last_update_time = None
 
         # Compute the width of the counters and build the format string.
         self.counters_width = 1  # [
         for layout in self.counters_fmt:
             self.counters_width += self.limit_digits
             # | (or ']' for the last one)
             self.counters_width += 1
 
@@ -74,27 +76,32 @@ class ProgressBar(object):
         pct = int(100.0 * current / self.limit)
         sys.stdout.write('{:3d}% '.format(pct))
 
         barlen = int(1.0 * self.barlen * current / self.limit) - 1
         bar = '=' * barlen + '>' + ' ' * (self.barlen - barlen - 1)
         sys.stdout.write(bar + '|')
 
         # Update the bar.
-        dt = datetime.now() - self.t0
+        now = datetime.now()
+        dt = now - self.t0
         dt = dt.seconds + dt.microseconds * 1e-6
         sys.stdout.write('{:6.1f}s'.format(dt))
         Terminal.clear_right()
 
         # Force redisplay, since we didn't write a \n.
         sys.stdout.flush()
 
+        self.last_update_time = now
+
     def poke(self):
         if not self.prior:
             return
+        if datetime.now() - self.last_update_time < self.update_granularity():
+            return
         self.update(*self.prior)
 
     def finish(self, complete=True):
         if not self.prior:
             sys.stdout.write('No test run... You can try adding'
                              ' --run-slow-tests or --run-skipped to run more tests\n')
             return
         final_count = self.limit if complete else self.prior[0]