16
16
from bzrlib.ui import text
18
18
p = optparse.OptionParser()
19
p.add_option('--quick', default=False, action='store_true')
19
20
p.add_option('--max-combinations', default=500, type=int)
20
21
p.add_option('--lsprof', default=None, type=str)
21
22
opts, args = p.parse_args(sys.argv[1:])
22
24
trace.enable_default_logging()
23
25
ui.ui_factory = text.TextUIFactory()
27
29
b = branch.Branch.open(args[0])
67
70
combinations = random.sample(combinations, opts.max_combinations)
69
72
print ' %d combinations' % (len(combinations),)
71
known_g = _known_graph_py.KnownGraph(parent_map)
72
if opts.lsprof is not None:
73
h_known = commands.apply_lsprofiled(opts.lsprof,
74
all_heads_comp, known_g, combinations)
76
h_known = all_heads_comp(known_g, combinations)
78
print "Known: %.3fs" % (t2-t1,)
79
print " %s" % (graph._counters,)
81
known_g = _known_graph_pyx.KnownGraph(parent_map)
82
if opts.lsprof is not None:
83
h_known = commands.apply_lsprofiled(opts.lsprof,
84
all_heads_comp, known_g, combinations)
86
h_known = all_heads_comp(known_g, combinations)
88
print "Known (pyx): %.3fs" % (t2-t1,)
89
print " %s" % (graph._counters,)
90
simple_g = graph.Graph(graph.DictParentsProvider(parent_map))
91
graph._counters[1] = 0
92
graph._counters[2] = 0
93
h_simple = all_heads_comp(simple_g, combinations)
95
print "Orig: %.3fs" % (t3-t2,)
96
print " %s" % (graph._counters,)
97
if h_simple != h_known:
98
import pdb; pdb.set_trace()
99
print 'ratio: %.3fs' % ((t2-t1) / (t3-t2))
74
def combi_graph(graph_klass, comb):
76
graph._counters[1] = 0
77
graph._counters[2] = 0
80
g = graph_klass(parent_map)
81
if opts.lsprof is not None:
82
heads = commands.apply_lsprofiled(opts.lsprof, all_heads_comp, g, comb)
84
heads = all_heads_comp(g, comb)
86
return dict(elapsed=(end - begin), graph=g, heads=heads)
89
print '%s: %.3fs' % (name, g['elapsed'])
91
for c in graph._counters:
95
print ' %s' % (graph._counters,)
97
known_python = combi_graph(_known_graph_py.KnownGraph, combinations)
98
report('Known', known_python)
100
known_pyrex = combi_graph(_known_graph_pyx.KnownGraph, combinations)
101
report('Known (pyx)', known_pyrex)
103
def _simple_graph(parent_map):
104
return graph.Graph(graph.DictParentsProvider(parent_map))
107
if known_python['heads'] != known_pyrex['heads']:
108
import pdb; pdb.set_trace()
109
print 'ratio: %.3fs' % (known_pyrex['elapsed'] / known_python['elapsed'])
111
orig = combi_graph(_simple_graph, combinations)
114
if orig['heads'] != known_pyrex['heads']:
115
import pdb; pdb.set_trace()
117
print 'ratio: %.3fs' % (known_pyrex['elapsed'] / orig['elapsed'])