]> arthur.barton.de Git - bup.git/blobdiff - cmd/margin-cmd.py
README.md: mention workaround for pwd test issue
[bup.git] / cmd / margin-cmd.py
index e61d0573aba00fde59c4583f8236b0b38f78abe5..9b7fd60a18efd24ab1801f32bcf02623be0cd3c1 100755 (executable)
@@ -1,8 +1,9 @@
 #!/usr/bin/env python
-import sys, struct
+import sys, struct, math
 from bup import options, git, _helpers
 from bup.helpers import *
 
+POPULATION_OF_EARTH=6.7e9  # as of September, 2010
 
 optspec = """
 bup margin
@@ -10,7 +11,7 @@ bup margin
 predict    Guess object offsets and report the maximum deviation
 ignore-midx  Don't use midx files; use only plain pack idx files.
 """
-o = options.Options('bup margin', optspec)
+o = options.Options(optspec)
 (opt, flags, extra) = o.parse(sys.argv[1:])
 
 if extra:
@@ -51,3 +52,16 @@ else:
         longmatch = max(longmatch, pm)
         last = i
     print longmatch
+    log('%d matching prefix bits\n' % longmatch)
+    doublings = math.log(len(mi), 2)
+    bpd = longmatch / doublings
+    log('%.2f bits per doubling\n' % bpd)
+    remain = 160 - longmatch
+    rdoublings = remain / bpd
+    log('%d bits (%.2f doublings) remaining\n' % (remain, rdoublings))
+    larger = 2**rdoublings
+    log('%g times larger is possible\n' % larger)
+    perperson = larger/POPULATION_OF_EARTH
+    log('\nEveryone on earth could have %d data sets like yours, all in one\n'
+        'repository, and we would expect 1 object collision.\n'
+        % int(perperson))