]> arthur.barton.de Git - bup.git/commitdiff
cmd/save: update the progress meter less often.
authorAvery Pennarun <apenwarr@gmail.com>
Sat, 31 Jul 2010 06:33:38 +0000 (02:33 -0400)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 31 Jul 2010 06:42:20 +0000 (02:42 -0400)
If you ran 'bup save' in an ssh sessio, you could end up sending huge
amounts of data back over ssh *just* to update the progress meter after
every single block!  Oops.  Limit the updates to only about 5 per second,
which is much better.

cmd/save-cmd.py

index 59b9cb06d3dd0fe6c1dce77e399db63a39e8762f..9078455f29d5444dbc8d4adea37f1631d8308055 100755 (executable)
@@ -74,8 +74,9 @@ def _pop(force_tree):
     return tree
 
 lastremain = None
+lastprint = 0
 def progress_report(n):
-    global count, subcount, lastremain
+    global count, subcount, lastremain, lastprint
     subcount += n
     cc = count + subcount
     pct = total and (cc*100.0/total) or 0
@@ -107,9 +108,11 @@ def progress_report(n):
             remainstr = '%dm%d' % (mins, secs)
         else:
             remainstr = '%ds' % secs
-    progress('Saving: %.2f%% (%d/%dk, %d/%d files) %s %s\r'
-             % (pct, cc/1024, total/1024, fcount, ftotal,
-                remainstr, kpsstr))
+    if now - lastprint > 0.1:
+        progress('Saving: %.2f%% (%d/%dk, %d/%d files) %s %s\r'
+                 % (pct, cc/1024, total/1024, fcount, ftotal,
+                    remainstr, kpsstr))
+        lastprint = now
 
 
 r = index.Reader(git.repo('bupindex'))