author | C. Masloch <pushbx@ulukai.org> |
Wed, 20 Apr 2022 19:24:39 +0200 | |
changeset 49449 | cfff73cab721 |
parent 49018 | a78c45a22ce4 |
child 49459 | df1d4e442c08 |
permissions | -rw-r--r-- |
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 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
116 |
def compare(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
|
117 |
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
|
118 |
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
|
119 |
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
|
120 |
revs = res["nb-revs"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
121 |
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
|
122 |
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
|
123 |
roundtrips = res["total-roundtrips"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
124 |
queries = res["total-queries"] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
125 |
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
|
126 |
print( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
127 |
repo, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
128 |
format_case(local_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
129 |
format_case(remote_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
130 |
variant, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
131 |
roundtrips, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
132 |
queries, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
133 |
revs, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
134 |
local_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
135 |
common_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
136 |
) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
137 |
else: |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
138 |
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
|
139 |
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
|
140 |
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
|
141 |
print( |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
142 |
repo, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
143 |
format_case(local_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
144 |
format_case(remote_case), |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
145 |
variant, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
146 |
roundtrips, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
147 |
queries, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
148 |
revs, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
149 |
local_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
150 |
common_heads, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
151 |
undecided, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
152 |
undecided_common, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
153 |
undecided_missing, |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
154 |
) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
155 |
return 0 |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
156 |
|
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 |
def process(case, variant): |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
159 |
(repo, left, right) = case |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
160 |
cmd = list(CMD_BASE) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
161 |
cmd.append('-R') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
162 |
cmd.append(repo) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
163 |
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
|
164 |
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
|
165 |
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
|
166 |
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
|
167 |
cmd.extend(variant) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
168 |
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
|
169 |
out, err = s.communicate() |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
170 |
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
|
171 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
172 |
|
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
173 |
if __name__ == '__main__': |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
174 |
if len(sys.argv) != 4: |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
175 |
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
|
176 |
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
|
177 |
sys.exit(128) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
178 |
repo = sys.argv[1] |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
179 |
local_case = sys.argv[2].split('-') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
180 |
local_case = (local_case[0],) + tuple(int(x) for x in local_case[1:]) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
181 |
remote_case = sys.argv[3].split('-') |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
182 |
remote_case = (remote_case[0],) + tuple(int(x) for x in remote_case[1:]) |
a78c45a22ce4
perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff
changeset
|
183 |
sys.exit(compare(repo, local_case, remote_case)) |