bzr branch
http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
1 |
#!/usr/bin/env python2.4
|
2 |
from itertools import izip |
|
|
0.9.15
by Aaron Bentley
Make mpregen output a psuedo-knit |
3 |
from StringIO import StringIO |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
4 |
import sys |
5 |
import time |
|
6 |
||
|
0.9.15
by Aaron Bentley
Make mpregen output a psuedo-knit |
7 |
from bzrlib.tuned_gzip import GzipFile |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
8 |
from bzrlib.workingtree import WorkingTree |
9 |
||
10 |
from multiparent import MultiVersionedFile |
|
11 |
single_parent = False |
|
12 |
if len(sys.argv) > 1 and len(sys.argv) < 4: |
|
13 |
wt, path = WorkingTree.open_containing(sys.argv[-1]) |
|
14 |
if len(sys.argv) == 3: |
|
15 |
assert sys.argv[1] == '--single' |
|
16 |
single_parent = True |
|
17 |
else: |
|
18 |
print >> sys.stderr, 'Usage: mpknit [--single] FILENAME' |
|
19 |
sys.exit(3) |
|
20 |
||
21 |
bt = wt.branch.repository.revision_tree(wt.last_revision()) |
|
22 |
file_id = wt.path2id(path) |
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
23 |
file_weave = wt.branch.repository.get_inventory_weave() |
24 |
#file_weave = bt.get_weave(file_id)
|
|
|
0.9.17
by Aaron Bentley
Dynamically select snapshots based on all parents |
25 |
#file_weave.enable_cache()
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
26 |
revisions = set(file_weave.versions()) |
27 |
ft_set = set(r for r in revisions if file_weave._index.get_method(r) |
|
28 |
== 'fulltext') |
|
|
0.9.17
by Aaron Bentley
Dynamically select snapshots based on all parents |
29 |
vf = MultiVersionedFile(25) |
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
30 |
#files = {}
|
31 |
#for version_id in revisions:
|
|
32 |
# lines = [a + ' ' + l for a, l in file_weave.annotate_iter(version_id)]
|
|
33 |
# files[version_id] = lines
|
|
|
0.9.15
by Aaron Bentley
Make mpregen output a psuedo-knit |
34 |
#files = dict(izip(ancestry, file_weave.get_line_list(ancestry)))
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
35 |
total = len(revisions) |
36 |
while len(revisions) > 0: |
|
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
37 |
added = set() |
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
38 |
for revision in revisions: |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
39 |
parents = file_weave.get_parents(revision) |
40 |
if [p for p in parents if p not in vf._diffs] != []: |
|
41 |
continue
|
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
42 |
lines = file_weave.get_lines(revision) |
|
0.9.17
by Aaron Bentley
Dynamically select snapshots based on all parents |
43 |
# vf.add_version(lines, revision, parents,
|
44 |
# force_snapshot=(revision in ft_set))
|
|
45 |
vf.add_version(lines, revision, parents) |
|
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
46 |
added.add(revision) |
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
47 |
vf.clear_cache() |
48 |
revisions = [r for r in revisions if r not in added] |
|
49 |
print >> sys.stderr, "%.1f %%" % ((((total - len(revisions)) * 100.0) |
|
50 |
/ total)) |
|
51 |
print >> sys.stderr, file_weave |
|
52 |
print >> sys.stderr, "%d fulltexts" % len(ft_set) |
|
53 |
print >> sys.stderr, "%d snapshots" % len(vf._snapshots) |
|
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
54 |
vf.clear_cache() |
55 |
if False: |
|
56 |
for revision_id in file_weave.get_ancestry( |
|
57 |
[bt.inventory[file_id].revision]): |
|
58 |
if vf.get_line_list([revision_id])[0] != \ |
|
59 |
file_weave.get_lines(revision_id): |
|
60 |
open(revision_id + '.old', 'wb').writelines( |
|
61 |
file_weave.get_lines(revision_id)) |
|
62 |
open(revision_id + '.new', 'wb').writelines( |
|
63 |
vf.get_line_list(revision_id)[0]) |
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
64 |
if True: |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
65 |
revisions = file_weave.get_ancestry( |
66 |
[bt.inventory[file_id].revision])[-1:] |
|
67 |
from bzrlib.lsprof import profile |
|
68 |
ret, stats = profile(vf.get_line_list, revisions) |
|
69 |
stats.sort() |
|
70 |
stats.pprint() |
|
71 |
start = time.clock() |
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
72 |
print revisions |
|
0.9.12
by Aaron Bentley
Make benchmarks for mp |
73 |
for x in range(1000): |
74 |
vf.clear_cache() |
|
75 |
vf.get_line_list(revisions) |
|
76 |
print time.clock() - start |
|
77 |
start = time.clock() |
|
78 |
for x in range(1000): |
|
79 |
file_weave.get_line_list(revisions) |
|
80 |
print time.clock() - start |
|
|
0.9.16
by Aaron Bentley
More control over snapshotting, disable caching for inventory |
81 |
if False: |
82 |
revisions = file_weave.versions() |
|
|
0.9.15
by Aaron Bentley
Make mpregen output a psuedo-knit |
83 |
|
84 |
for revision, diff in vf._diffs.iteritems(): |
|
85 |
sio = StringIO() |
|
86 |
data_file = GzipFile(None, mode='wb', fileobj=sio) |
|
87 |
print >> data_file, 'version %s' % revision |
|
88 |
data_file.writelines(diff.to_patch()) |
|
89 |
data_file.close() |
|
90 |
sys.stdout.write(sio.getvalue()) |