16
from bzrlib.ui import text
17
from breezy.ui import text
18
19
p = optparse.OptionParser()
19
20
p.add_option('--quick', default=False, action='store_true')
24
25
trace.enable_default_logging()
25
26
ui.ui_factory = text.TextUIFactory()
28
begin = osutils.perf_counter()
29
30
b = branch.Branch.open(args[0])
31
32
b = branch.Branch.open('.')
34
34
g = b.repository.get_graph()
35
35
parent_map = dict(p for p in g.iter_ancestry([b.last_revision()])
37
end = osutils.perf_counter()
41
print 'Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin)
39
print('Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin))
43
41
def all_heads_comp(g, combinations):
45
pb = ui.ui_factory.nested_progress_bar()
43
with ui.ui_factory.nested_progress_bar() as pb:
47
44
for idx, combo in enumerate(combinations):
48
45
if idx & 0x1f == 0:
49
46
pb.update('proc', idx, len(combinations))
50
47
h.append(g.heads(combo))
72
67
if opts.max_combinations > 0 and len(combinations) > opts.max_combinations:
73
68
combinations = random.sample(combinations, opts.max_combinations)
75
print ' %d combinations' % (len(combinations),)
70
print(' %d combinations' % (len(combinations),))
77
72
def combi_graph(graph_klass, comb):
79
74
graph._counters[1] = 0
80
75
graph._counters[2] = 0
77
begin = osutils.perf_counter()
83
78
g = graph_klass(parent_map)
84
79
if opts.lsprof is not None:
85
80
heads = commands.apply_lsprofiled(opts.lsprof, all_heads_comp, g, comb)
87
82
heads = all_heads_comp(g, comb)
83
end = osutils.perf_counter()
89
84
return dict(elapsed=(end - begin), graph=g, heads=heads)
91
86
def report(name, g):
92
print '%s: %.3fs' % (name, g['elapsed'])
87
print('%s: %.3fs' % (name, g['elapsed']))
93
88
counters_used = False
94
89
for c in graph._counters:
96
91
counters_used = True
98
print ' %s' % (graph._counters,)
93
print(' %s' % (graph._counters,))
100
95
known_python = combi_graph(_known_graph_py.KnownGraph, combinations)
101
96
report('Known', known_python)
110
105
if known_python['heads'] != known_pyrex['heads']:
111
106
import pdb; pdb.set_trace()
112
print 'ratio: %.1f:1 faster' % (
113
known_python['elapsed'] / known_pyrex['elapsed'],)
107
print('ratio: %.1f:1 faster' % (
108
known_python['elapsed'] / known_pyrex['elapsed'],))
115
110
orig = combi_graph(_simple_graph, combinations)
116
111
report('Orig', orig)
118
113
if orig['heads'] != known_pyrex['heads']:
119
114
import pdb; pdb.set_trace()
121
print 'ratio: %.1f:1 faster' % (
122
orig['elapsed'] / known_pyrex['elapsed'],)
116
print('ratio: %.1f:1 faster' % (
117
orig['elapsed'] / known_pyrex['elapsed'],))