/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: 2017-09-01 07:15:43 UTC
  • mfrom: (6770.3.2 py3_test_cleanup)
  • Revision ID: jelmer@jelmer.uk-20170901071543-1t83321xkog9qrxh
Merge lp:~gz/brz/py3_test_cleanup

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
35
                         if p[1] is not None)
37
 
finally:
38
 
    b.unlock()
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 = []
72
69
if opts.max_combinations > 0 and len(combinations) > opts.max_combinations:
73
70
    combinations = random.sample(combinations, opts.max_combinations)
74
71
 
75
 
print '      %d combinations' % (len(combinations),)
 
72
print('      %d combinations' % (len(combinations),))
76
73
 
77
74
def combi_graph(graph_klass, comb):
78
75
    # DEBUG
89
86
    return dict(elapsed=(end - begin), graph=g, heads=heads)
90
87
 
91
88
def report(name, g):
92
 
    print '%s: %.3fs' % (name, g['elapsed'])
 
89
    print('%s: %.3fs' % (name, g['elapsed']))
93
90
    counters_used = False
94
91
    for c in graph._counters:
95
92
        if c:
96
93
            counters_used = True
97
94
    if counters_used:
98
 
        print '  %s' % (graph._counters,)
 
95
        print('  %s' % (graph._counters,))
99
96
 
100
97
known_python = combi_graph(_known_graph_py.KnownGraph, combinations)
101
98
report('Known', known_python)
109
106
if opts.quick:
110
107
    if known_python['heads'] != known_pyrex['heads']:
111
108
        import pdb; pdb.set_trace()
112
 
    print 'ratio: %.1f:1 faster' % (
113
 
        known_python['elapsed'] / known_pyrex['elapsed'],)
 
109
    print('ratio: %.1f:1 faster' % (
 
110
        known_python['elapsed'] / known_pyrex['elapsed'],))
114
111
else:
115
112
    orig = combi_graph(_simple_graph, combinations)
116
113
    report('Orig', orig)
118
115
    if orig['heads'] != known_pyrex['heads']:
119
116
        import pdb; pdb.set_trace()
120
117
 
121
 
    print 'ratio: %.1f:1 faster' % (
122
 
        orig['elapsed'] / known_pyrex['elapsed'],)
 
118
    print('ratio: %.1f:1 faster' % (
 
119
        orig['elapsed'] / known_pyrex['elapsed'],))