/brz/remove-bazaar

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/brz/remove-bazaar

« back to all changes in this revision

Viewing changes to tools/time_graph.py

  • Committer: John Arbash Meinel
  • Date: 2009-06-17 19:08:25 UTC
  • mto: This revision was merged to the branch mainline in revision 4460.
  • Revision ID: john@arbash-meinel.com-20090617190825-ktfk82li57rf2im6
It seems that fetch() no longer returns the number of revisions fetched.
It still does for *some* InterRepository fetch paths, but the generic one does not.
It is also not easy to get it to, since the Source and Sink are the ones
that would know how many keys were transmitted, and they are potentially 'remote'
objects.

This was also only tested to occur as a by-product in a random 'test_commit' test.
I assume if we really wanted the assurance, we would have a per_repo or interrepo
test for it.

Show diffs side-by-side

added added

removed removed

Lines of Context:
16
16
from bzrlib.ui import text
17
17
 
18
18
p = optparse.OptionParser()
19
 
p.add_option('--quick', default=False, action='store_true')
20
19
p.add_option('--max-combinations', default=500, type=int)
21
20
p.add_option('--lsprof', default=None, type=str)
22
21
opts, args = p.parse_args(sys.argv[1:])
23
 
 
24
22
trace.enable_default_logging()
25
23
ui.ui_factory = text.TextUIFactory()
26
24
 
27
 
begin = time.clock()
28
25
if len(args) >= 1:
29
26
    b = branch.Branch.open(args[0])
30
27
else:
36
33
                         if p[1] is not None)
37
34
finally:
38
35
    b.unlock()
39
 
end = time.clock()
40
36
 
41
 
print 'Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin)
 
37
print 'Found %d nodes' % (len(parent_map),)
42
38
 
43
39
def all_heads_comp(g, combinations):
44
40
    h = []
51
47
    finally:
52
48
        pb.finished()
53
49
    return h
54
 
 
55
50
combinations = []
56
51
# parents = parent_map.keys()
57
52
# for p1 in parents:
66
61
for revision_id, parent_ids in parent_map.iteritems():
67
62
    if parent_ids is not None and len(parent_ids) > 1:
68
63
        combinations.append(parent_ids)
69
 
# The largest portion of the graph that has to be walked for a heads() check
70
 
# combinations = [('john@arbash-meinel.com-20090312021943-tu6tcog48aiujx4s',
71
 
#                  'john@arbash-meinel.com-20090312130552-09xa2xsitf6rilzc')]
72
64
if opts.max_combinations > 0 and len(combinations) > opts.max_combinations:
73
65
    combinations = random.sample(combinations, opts.max_combinations)
74
66
 
75
67
print '      %d combinations' % (len(combinations),)
76
 
 
77
 
def combi_graph(graph_klass, comb):
78
 
    # DEBUG
79
 
    graph._counters[1] = 0
80
 
    graph._counters[2] = 0
81
 
 
82
 
    begin = time.clock()
83
 
    g = graph_klass(parent_map)
84
 
    if opts.lsprof is not None:
85
 
        heads = commands.apply_lsprofiled(opts.lsprof, all_heads_comp, g, comb)
86
 
    else:
87
 
        heads = all_heads_comp(g, comb)
88
 
    end = time.clock()
89
 
    return dict(elapsed=(end - begin), graph=g, heads=heads)
90
 
 
91
 
def report(name, g):
92
 
    print '%s: %.3fs' % (name, g['elapsed'])
93
 
    counters_used = False
94
 
    for c in graph._counters:
95
 
        if c:
96
 
            counters_used = True
97
 
    if counters_used:
98
 
        print '  %s' % (graph._counters,)
99
 
 
100
 
known_python = combi_graph(_known_graph_py.KnownGraph, combinations)
101
 
report('Known', known_python)
102
 
 
103
 
known_pyrex = combi_graph(_known_graph_pyx.KnownGraph, combinations)
104
 
report('Known (pyx)', known_pyrex)
105
 
 
106
 
def _simple_graph(parent_map):
107
 
    return graph.Graph(graph.DictParentsProvider(parent_map))
108
 
 
109
 
if opts.quick:
110
 
    if known_python['heads'] != known_pyrex['heads']:
111
 
        import pdb; pdb.set_trace()
112
 
    print 'ratio: %.1f:1 faster' % (
113
 
        known_python['elapsed'] / known_pyrex['elapsed'],)
114
 
else:
115
 
    orig = combi_graph(_simple_graph, combinations)
116
 
    report('Orig', orig)
117
 
 
118
 
    if orig['heads'] != known_pyrex['heads']:
119
 
        import pdb; pdb.set_trace()
120
 
 
121
 
    print 'ratio: %.1f:1 faster' % (
122
 
        orig['elapsed'] / known_pyrex['elapsed'],)
 
68
t1 = time.clock()
 
69
known_g = _known_graph_py.KnownGraph(parent_map)
 
70
if opts.lsprof is not None:
 
71
    h_known = commands.apply_lsprofiled(opts.lsprof,
 
72
        all_heads_comp, known_g, combinations)
 
73
else:
 
74
    h_known = all_heads_comp(known_g, combinations)
 
75
t2 = time.clock()
 
76
print "Known: %.3fs" % (t2-t1,)
 
77
print "  %s" % (graph._counters,)
 
78
t1 = time.clock()
 
79
known_g = _known_graph_pyx.KnownGraph(parent_map)
 
80
if opts.lsprof is not None:
 
81
    h_known = commands.apply_lsprofiled(opts.lsprof,
 
82
        all_heads_comp, known_g, combinations)
 
83
else:
 
84
    h_known = all_heads_comp(known_g, combinations)
 
85
t2 = time.clock()
 
86
print "Known (pyx): %.3fs" % (t2-t1,)
 
87
print "  %s" % (graph._counters,)
 
88
simple_g = graph.Graph(graph.DictParentsProvider(parent_map))
 
89
graph._counters[1] = 0
 
90
graph._counters[2] = 0
 
91
h_simple = all_heads_comp(simple_g, combinations)
 
92
t3 = time.clock()
 
93
print "Orig: %.3fs" % (t3-t2,)
 
94
print "  %s" % (graph._counters,)
 
95
if h_simple != h_known:
 
96
    import pdb; pdb.set_trace()
 
97
print 'ratio: %.3fs' % ((t2-t1) / (t3-t2))