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