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 |
|
3 |
import sys |
|
4 |
import time |
|
5 |
||
6 |
from bzrlib.workingtree import WorkingTree |
|
7 |
||
8 |
from multiparent import MultiVersionedFile |
|
9 |
single_parent = False |
|
10 |
if len(sys.argv) > 1 and len(sys.argv) < 4: |
|
11 |
wt, path = WorkingTree.open_containing(sys.argv[-1]) |
|
12 |
if len(sys.argv) == 3: |
|
13 |
assert sys.argv[1] == '--single' |
|
14 |
single_parent = True |
|
15 |
else: |
|
16 |
print >> sys.stderr, 'Usage: mpknit [--single] FILENAME' |
|
17 |
sys.exit(3) |
|
18 |
||
19 |
bt = wt.branch.repository.revision_tree(wt.last_revision()) |
|
20 |
file_id = wt.path2id(path) |
|
21 |
file_weave = bt.get_weave(file_id) |
|
22 |
file_weave.enable_cache() |
|
23 |
vf = MultiVersionedFile() |
|
24 |
ancestry = set(file_weave.get_ancestry([bt.inventory[file_id].revision])) |
|
25 |
files = dict(izip(ancestry, file_weave.get_line_list(ancestry))) |
|
26 |
while len(ancestry) > 0: |
|
27 |
added = set() |
|
28 |
for revision in ancestry: |
|
29 |
parents = file_weave.get_parents(revision) |
|
30 |
if [p for p in parents if p not in vf._diffs] != []: |
|
31 |
continue
|
|
32 |
lines = files[revision] |
|
33 |
vf.add_version(lines, revision, parents) |
|
34 |
added.add(revision) |
|
35 |
ancestry = [r for r in ancestry if r not in added] |
|
36 |
vf.clear_cache() |
|
37 |
if False: |
|
38 |
for revision_id in file_weave.get_ancestry( |
|
39 |
[bt.inventory[file_id].revision]): |
|
40 |
if vf.get_line_list([revision_id])[0] != \ |
|
41 |
file_weave.get_lines(revision_id): |
|
42 |
open(revision_id + '.old', 'wb').writelines( |
|
43 |
file_weave.get_lines(revision_id)) |
|
44 |
open(revision_id + '.new', 'wb').writelines( |
|
45 |
vf.get_line_list(revision_id)[0]) |
|
46 |
if True: |
|
47 |
revisions = file_weave.get_ancestry( |
|
48 |
[bt.inventory[file_id].revision])[-1:] |
|
49 |
from bzrlib.lsprof import profile |
|
50 |
ret, stats = profile(vf.get_line_list, revisions) |
|
51 |
stats.sort() |
|
52 |
stats.pprint() |
|
53 |
start = time.clock() |
|
54 |
for x in range(1000): |
|
55 |
vf.clear_cache() |
|
56 |
vf.get_line_list(revisions) |
|
57 |
print time.clock() - start |
|
58 |
start = time.clock() |
|
59 |
for x in range(1000): |
|
60 |
file_weave.get_line_list(revisions) |
|
61 |
print time.clock() - start |