/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: Jelmer Vernooij
  • Date: 2019-02-04 01:01:24 UTC
  • mto: This revision was merged to the branch mainline in revision 7268.
  • Revision ID: jelmer@jelmer.uk-20190204010124-ni0i4qc6f5tnbvux
Fix source tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
import time
5
5
import sys
6
6
import optparse
7
 
from bzrlib import (
 
7
from breezy import (
8
8
    branch,
9
9
    commands,
10
10
    graph,
13
13
    _known_graph_py,
14
14
    _known_graph_pyx,
15
15
    )
16
 
from bzrlib.ui import text
 
16
from breezy.ui import text
17
17
 
18
18
p = optparse.OptionParser()
19
19
p.add_option('--quick', default=False, action='store_true')
29
29
    b = branch.Branch.open(args[0])
30
30
else:
31
31
    b = branch.Branch.open('.')
32
 
b.lock_read()
33
 
try:
 
32
with b.lock_read():
34
33
    g = b.repository.get_graph()
35
34
    parent_map = dict(p for p in g.iter_ancestry([b.last_revision()])
36
 
                         if p[1] is not None)
37
 
finally:
38
 
    b.unlock()
 
35
                      if p[1] is not None)
39
36
end = time.clock()
40
37
 
41
 
print 'Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin)
 
38
print('Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin))
42
39
 
43
40
def all_heads_comp(g, combinations):
44
41
    h = []
45
 
    pb = ui.ui_factory.nested_progress_bar()
46
 
    try:
 
42
    with ui.ui_factory.nested_progress_bar() as pb:
47
43
        for idx, combo in enumerate(combinations):
48
44
            if idx & 0x1f == 0:
49
45
                pb.update('proc', idx, len(combinations))
50
46
            h.append(g.heads(combo))
51
 
    finally:
52
 
        pb.finished()
53
47
    return h
54
48
 
55
49
combinations = []
72
66
if opts.max_combinations > 0 and len(combinations) > opts.max_combinations:
73
67
    combinations = random.sample(combinations, opts.max_combinations)
74
68
 
75
 
print '      %d combinations' % (len(combinations),)
 
69
print('      %d combinations' % (len(combinations),))
76
70
 
77
71
def combi_graph(graph_klass, comb):
78
72
    # DEBUG
89
83
    return dict(elapsed=(end - begin), graph=g, heads=heads)
90
84
 
91
85
def report(name, g):
92
 
    print '%s: %.3fs' % (name, g['elapsed'])
 
86
    print('%s: %.3fs' % (name, g['elapsed']))
93
87
    counters_used = False
94
88
    for c in graph._counters:
95
89
        if c:
96
90
            counters_used = True
97
91
    if counters_used:
98
 
        print '  %s' % (graph._counters,)
 
92
        print('  %s' % (graph._counters,))
99
93
 
100
94
known_python = combi_graph(_known_graph_py.KnownGraph, combinations)
101
95
report('Known', known_python)
109
103
if opts.quick:
110
104
    if known_python['heads'] != known_pyrex['heads']:
111
105
        import pdb; pdb.set_trace()
112
 
    print 'ratio: %.1f:1 faster' % (
113
 
        known_python['elapsed'] / known_pyrex['elapsed'],)
 
106
    print('ratio: %.1f:1 faster' % (
 
107
        known_python['elapsed'] / known_pyrex['elapsed'],))
114
108
else:
115
109
    orig = combi_graph(_simple_graph, combinations)
116
110
    report('Orig', orig)
118
112
    if orig['heads'] != known_pyrex['heads']:
119
113
        import pdb; pdb.set_trace()
120
114
 
121
 
    print 'ratio: %.1f:1 faster' % (
122
 
        orig['elapsed'] / known_pyrex['elapsed'],)
 
115
    print('ratio: %.1f:1 faster' % (
 
116
        orig['elapsed'] / known_pyrex['elapsed'],))