author | Pierre-Yves DAVID <pierre-yves.david@octobus.net> |
Sat, 04 Jun 2022 18:58:07 +0200 | |
changeset 49460 | 3c026138f234 |
parent 49459 | df1d4e442c08 |
child 49461 | ebbaf6a77807 |
permissions | -rwxr-xr-x |
49018
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
1 |
#!/usr/bin/env python3 |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
2 |
# compare various algorithm variants for a given case |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
3 |
# |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
4 |
# search-discovery-case REPO LOCAL_CASE REMOTE_CASE |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
5 |
# |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
6 |
# The description for the case input uses the same format as the ouput of |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
7 |
# search-discovery-case |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
8 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
9 |
import json |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
10 |
import os |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
11 |
import subprocess |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
12 |
import sys |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
13 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
14 |
this_script = os.path.abspath(sys.argv[0]) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
15 |
script_name = os.path.basename(this_script) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
16 |
this_dir = os.path.dirname(this_script) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
17 |
hg_dir = os.path.join(this_dir, '..', '..') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
18 |
HG_REPO = os.path.normpath(hg_dir) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
19 |
HG_BIN = os.path.join(HG_REPO, 'hg') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
20 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
21 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
22 |
SUBSET_PATH = os.path.join(HG_REPO, 'contrib', 'perf-utils', 'subsetmaker.py') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
23 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
24 |
CMD_BASE = ( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
25 |
HG_BIN, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
26 |
'debugdiscovery', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
27 |
'--template', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
28 |
'json', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
29 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
30 |
'extensions.subset=%s' % SUBSET_PATH, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
31 |
) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
32 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
33 |
# --old |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
34 |
# --nonheads |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
35 |
# |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
36 |
# devel.discovery.exchange-heads=True |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
37 |
# devel.discovery.grow-sample=True |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
38 |
# devel.discovery.grow-sample.dynamic=True |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
39 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
40 |
VARIANTS = { |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
41 |
'tree-discovery': ('--old',), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
42 |
'set-discovery-basic': ( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
43 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
44 |
'devel.discovery.exchange-heads=no', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
45 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
46 |
'devel.discovery.grow-sample=no', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
47 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
48 |
'devel.discovery.grow-sample.dynamic=no', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
49 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
50 |
'devel.discovery.randomize=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
51 |
), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
52 |
'set-discovery-heads': ( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
53 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
54 |
'devel.discovery.exchange-heads=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
55 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
56 |
'devel.discovery.grow-sample=no', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
57 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
58 |
'devel.discovery.grow-sample.dynamic=no', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
59 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
60 |
'devel.discovery.randomize=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
61 |
), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
62 |
'set-discovery-grow-sample': ( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
63 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
64 |
'devel.discovery.exchange-heads=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
65 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
66 |
'devel.discovery.grow-sample=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
67 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
68 |
'devel.discovery.grow-sample.dynamic=no', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
69 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
70 |
'devel.discovery.randomize=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
71 |
), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
72 |
'set-discovery-dynamic-sample': ( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
73 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
74 |
'devel.discovery.exchange-heads=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
75 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
76 |
'devel.discovery.grow-sample=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
77 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
78 |
'devel.discovery.grow-sample.dynamic=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
79 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
80 |
'devel.discovery.randomize=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
81 |
), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
82 |
'set-discovery-default': ( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
83 |
'--config', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
84 |
'devel.discovery.randomize=yes', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
85 |
), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
86 |
} |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
87 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
88 |
VARIANTS_KEYS = [ |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
89 |
'tree-discovery', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
90 |
'set-discovery-basic', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
91 |
'set-discovery-heads', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
92 |
'set-discovery-grow-sample', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
93 |
'set-discovery-dynamic-sample', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
94 |
'set-discovery-default', |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
95 |
] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
96 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
97 |
assert set(VARIANTS.keys()) == set(VARIANTS_KEYS) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
98 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
99 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
100 |
def format_case(case): |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
101 |
return '-'.join(str(s) for s in case) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
102 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
103 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
104 |
def to_revsets(case): |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
105 |
t = case[0] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
106 |
if t == 'scratch': |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
107 |
return 'not scratch(all(), %d, "%d")' % (case[1], case[2]) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
108 |
elif t == 'randomantichain': |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
109 |
return '::randomantichain(all(), "%d")' % case[1] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
110 |
elif t == 'rev': |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
111 |
return '::%d' % case[1] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
112 |
else: |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
113 |
assert False |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
114 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
115 |
|
49460
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
116 |
def compare( |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
117 |
repo, |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
118 |
local_case, |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
119 |
remote_case, |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
120 |
display_header=True, |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
121 |
): |
49018
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
122 |
case = (repo, local_case, remote_case) |
49460
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
123 |
if display_header: |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
124 |
print( |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
125 |
"#", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
126 |
"repo", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
127 |
"local-subset", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
128 |
"remote-subset", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
129 |
"discovery-variant", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
130 |
"roundtrips", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
131 |
"queries", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
132 |
"revs", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
133 |
"local-heads", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
134 |
"common-heads", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
135 |
"undecided-initial", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
136 |
"undecided-common", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
137 |
"undecided-missing", |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
138 |
) |
49018
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
139 |
for variant in VARIANTS_KEYS: |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
140 |
res = process(case, VARIANTS[variant]) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
141 |
revs = res["nb-revs"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
142 |
local_heads = res["nb-head-local"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
143 |
common_heads = res["nb-common-heads"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
144 |
roundtrips = res["total-roundtrips"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
145 |
queries = res["total-queries"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
146 |
if 'tree-discovery' in variant: |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
147 |
print( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
148 |
repo, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
149 |
format_case(local_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
150 |
format_case(remote_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
151 |
variant, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
152 |
roundtrips, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
153 |
queries, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
154 |
revs, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
155 |
local_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
156 |
common_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
157 |
) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
158 |
else: |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
159 |
undecided_common = res["nb-ini_und-common"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
160 |
undecided_missing = res["nb-ini_und-missing"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
161 |
undecided = undecided_common + undecided_missing |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
162 |
print( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
163 |
repo, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
164 |
format_case(local_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
165 |
format_case(remote_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
166 |
variant, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
167 |
roundtrips, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
168 |
queries, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
169 |
revs, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
170 |
local_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
171 |
common_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
172 |
undecided, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
173 |
undecided_common, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
174 |
undecided_missing, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
175 |
) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
176 |
return 0 |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
177 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
178 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
179 |
def process(case, variant): |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
180 |
(repo, left, right) = case |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
181 |
cmd = list(CMD_BASE) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
182 |
cmd.append('-R') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
183 |
cmd.append(repo) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
184 |
cmd.append('--local-as-revs') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
185 |
cmd.append(to_revsets(left)) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
186 |
cmd.append('--remote-as-revs') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
187 |
cmd.append(to_revsets(right)) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
188 |
cmd.extend(variant) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
189 |
s = subprocess.Popen(cmd, stdout=subprocess.PIPE) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
190 |
out, err = s.communicate() |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
191 |
return json.loads(out)[0] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
192 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
193 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
194 |
if __name__ == '__main__': |
49459
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
195 |
|
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
196 |
argv = sys.argv[:] |
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
197 |
|
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
198 |
kwargs = {} |
49460
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
199 |
# primitive arg parsing |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
200 |
if '--no-header' in argv: |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
201 |
kwargs['display_header'] = False |
3c026138f234
compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49459
diff
changeset
|
202 |
argv = [a for a in argv if a != '--no-header'] |
49459
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
203 |
|
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
204 |
if len(argv) != 4: |
49018
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
205 |
usage = f'USAGE: {script_name} REPO LOCAL_CASE REMOTE_CASE' |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
206 |
print(usage, file=sys.stderr) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
207 |
sys.exit(128) |
49459
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
208 |
repo = argv[1] |
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
209 |
local_case = argv[2].split('-') |
49018
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
210 |
local_case = (local_case[0],) + tuple(int(x) for x in local_case[1:]) |
49459
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
211 |
remote_case = argv[3].split('-') |
49018
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
212 |
remote_case = (remote_case[0],) + tuple(int(x) for x in remote_case[1:]) |
49459
df1d4e442c08
compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents:
49018
diff
changeset
|
213 |
sys.exit(compare(repo, local_case, remote_case, **kwargs)) |