/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: 2020-03-22 01:35:14 UTC
  • mfrom: (7490.7.6 work)
  • mto: This revision was merged to the branch mainline in revision 7499.
  • Revision ID: jelmer@jelmer.uk-20200322013514-7vw1ntwho04rcuj3
merge lp:brz/3.1.

Show diffs side-by-side

added added

removed removed

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