/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: Richard Wilbur
  • Date: 2016-02-04 19:07:28 UTC
  • mto: This revision was merged to the branch mainline in revision 6618.
  • Revision ID: richard.wilbur@gmail.com-20160204190728-p0zvfii6zase0fw7
Update COPYING.txt from the original http://www.gnu.org/licenses/gpl-2.0.txt  (Only differences were in whitespace.)  Thanks to Petr Stodulka for pointing out the discrepancy.

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