From: Avery Pennarun Date: Sat, 2 Jan 2010 06:45:14 +0000 (-0500) Subject: Fix 'bup split --bench'. X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=b8215e5898febb6bd87682e34cf4460bdf526445;p=packages%2Fb%2Fbup.git Fix 'bup split --bench'. This was broken earlier and apparently didn't have a test; now it does. --- diff --git a/Makefile b/Makefile index a84c41f..5b4fd4d 100644 --- a/Makefile +++ b/Makefile @@ -14,7 +14,7 @@ runtests: all runtests-cmdline: all @echo "Testing \"$@\" in Makefile:" - ./bup split -b tags1 + ./bup split --bench -b tags1 ./bup split -b testfile2 >tags2 diff -u tags1 tags2 || true wc -c testfile1 testfile2 diff --git a/cmd-split.py b/cmd-split.py index 732f608..29bbae3 100755 --- a/cmd-split.py +++ b/cmd-split.py @@ -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)) diff --git a/hashsplit.py b/hashsplit.py index 4a9e07a..a991ca7 100644 --- a/hashsplit.py +++ b/hashsplit.py @@ -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)