]> arthur.barton.de Git - bup.git/commitdiff
Fix 'bup split --bench'.
authorAvery Pennarun <apenwarr@gmail.com>
Sat, 2 Jan 2010 06:45:14 +0000 (01:45 -0500)
committerAvery Pennarun <apenwarr@gmail.com>
Sat, 2 Jan 2010 06:45:14 +0000 (01:45 -0500)
This was broken earlier and apparently didn't have a test; now it does.

Makefile
cmd-split.py
hashsplit.py

index a84c41f8b783298f17642fc482ac7dfbf30cfbc4..5b4fd4dc617c6b8b71248e751d8baa0d16aa577f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ runtests: all
        
 runtests-cmdline: all
        @echo "Testing \"$@\" in Makefile:"
-       ./bup split -b <testfile1 >tags1
+       ./bup split --bench -b <testfile1 >tags1
        ./bup split -b testfile2 >tags2
        diff -u tags1 tags2 || true
        wc -c testfile1 testfile2
index 732f608f3c95f13b4895808ee1e88f18a0d87cd4..29bbae31d1969e1f459f372b5a2c1ca354d0a952 100755 (executable)
@@ -35,6 +35,7 @@ if opt.commit or opt.name:
         print commit
 
 secs = time.time() - start_time
+size = hashsplit.total_split
 if opt.bench:
     log('\nbup: %.2fkbytes in %.2f secs = %.2f kbytes/sec\n'
-        % (ofs/1024., secs, ofs/1024./secs))
+        % (size/1024., secs, size/1024./secs))
index 4a9e07a299bf4ee904eae8439f05dc7e3ac81b57..a991ca7bce5cd145f8773a3da6261cc0cc96feb5 100644 (file)
@@ -93,8 +93,9 @@ def hashsplit_iter(files):
             lv = nv
 
 
-def split_to_tree(files):
-    shalist = []
+total_split = 0
+def split_to_shalist(files):
+    global total_split
     ofs = 0
     last_ofs = 0
     for (ofs, size, sha) in hashsplit_iter(files):
@@ -108,7 +109,12 @@ def split_to_tree(files):
             if cn > last_ofs or ofs == last_ofs: break
             bm /= 2
         last_ofs = cn
-        shalist.append(('100644', 'bup.chunk.%016x' % cn, sha))
+        total_split += size
+        yield ('100644', 'bup.chunk.%016x' % cn, sha)
+
+
+def split_to_tree(files):
+    shalist = list(split_to_shalist(files))
     tree = git.gen_tree(shalist)
     return (shalist, tree)