/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-06-08 23:30:31 UTC
  • mto: This revision was merged to the branch mainline in revision 6690.
  • Revision ID: jelmer@jelmer.uk-20170608233031-3qavls2o7a1pqllj
Update imports.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
#!/usr/bin/env python3
 
1
#!/usr/bin/env python
2
2
import random
3
3
import os
4
4
import time
8
8
    branch,
9
9
    commands,
10
10
    graph,
11
 
    osutils,
12
11
    ui,
13
12
    trace,
14
13
    _known_graph_py,
25
24
trace.enable_default_logging()
26
25
ui.ui_factory = text.TextUIFactory()
27
26
 
28
 
begin = osutils.perf_counter()
 
27
begin = time.clock()
29
28
if len(args) >= 1:
30
29
    b = branch.Branch.open(args[0])
31
30
else:
32
31
    b = branch.Branch.open('.')
33
 
with b.lock_read():
 
32
b.lock_read()
 
33
try:
34
34
    g = b.repository.get_graph()
35
35
    parent_map = dict(p for p in g.iter_ancestry([b.last_revision()])
36
 
                      if p[1] is not None)
37
 
end = osutils.perf_counter()
 
36
                         if p[1] is not None)
 
37
finally:
 
38
    b.unlock()
 
39
end = time.clock()
38
40
 
39
41
print('Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin))
40
42
 
41
43
def all_heads_comp(g, combinations):
42
44
    h = []
43
 
    with ui.ui_factory.nested_progress_bar() as pb:
 
45
    pb = ui.ui_factory.nested_progress_bar()
 
46
    try:
44
47
        for idx, combo in enumerate(combinations):
45
48
            if idx & 0x1f == 0:
46
49
                pb.update('proc', idx, len(combinations))
47
50
            h.append(g.heads(combo))
 
51
    finally:
 
52
        pb.finished()
48
53
    return h
49
54
 
50
55
combinations = []
74
79
    graph._counters[1] = 0
75
80
    graph._counters[2] = 0
76
81
 
77
 
    begin = osutils.perf_counter()
 
82
    begin = time.clock()
78
83
    g = graph_klass(parent_map)
79
84
    if opts.lsprof is not None:
80
85
        heads = commands.apply_lsprofiled(opts.lsprof, all_heads_comp, g, comb)
81
86
    else:
82
87
        heads = all_heads_comp(g, comb)
83
 
    end = osutils.perf_counter()
 
88
    end = time.clock()
84
89
    return dict(elapsed=(end - begin), graph=g, heads=heads)
85
90
 
86
91
def report(name, g):