/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: 2018-02-18 21:42:57 UTC
  • mto: This revision was merged to the branch mainline in revision 6859.
  • Revision ID: jelmer@jelmer.uk-20180218214257-jpevutp1wa30tz3v
Update TODO to reference Breezy, not Bazaar.

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:
33
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
 
end = osutils.perf_counter()
 
35
                         if p[1] is not None)
 
36
end = time.clock()
38
37
 
39
38
print('Found %d nodes, loaded in %.3fs' % (len(parent_map), end - begin))
40
39
 
41
40
def all_heads_comp(g, combinations):
42
41
    h = []
43
 
    with ui.ui_factory.nested_progress_bar() as pb:
 
42
    pb = ui.ui_factory.nested_progress_bar()
 
43
    try:
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()
48
50
    return h
49
51
 
50
52
combinations = []
74
76
    graph._counters[1] = 0
75
77
    graph._counters[2] = 0
76
78
 
77
 
    begin = osutils.perf_counter()
 
79
    begin = time.clock()
78
80
    g = graph_klass(parent_map)
79
81
    if opts.lsprof is not None:
80
82
        heads = commands.apply_lsprofiled(opts.lsprof, all_heads_comp, g, comb)
81
83
    else:
82
84
        heads = all_heads_comp(g, comb)
83
 
    end = osutils.perf_counter()
 
85
    end = time.clock()
84
86
    return dict(elapsed=(end - begin), graph=g, heads=heads)
85
87
 
86
88
def report(name, g):