annotate contrib/perf-utils/compare-discovery-case @ 49462:ef0b0f94d2e5

compare-disco: move case parsing into its own function This is open the way to the next changeset that will allow to specify a list of heads.
author Pierre-Yves DAVID <pierre-yves.david@octobus.net>
date Sat, 04 Jun 2022 19:10:51 +0200
parents ebbaf6a77807
children 5acbc550d987
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
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
49462
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
100 def parse_case(case):
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
101 case_type, case_args = case.split('-', 1)
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
102 case = (case_type,) + tuple(int(x) for x in case_args.split('-'))
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
103 return case
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
104
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
105
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
106 def format_case(case):
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
107 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
108
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
109
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
110 def to_revsets(case):
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
111 t = case[0]
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
112 if t == 'scratch':
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
113 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
114 elif t == 'randomantichain':
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
115 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
116 elif t == 'rev':
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
117 return '::%d' % case[1]
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
118 else:
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
119 assert False
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
120
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
121
49460
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
122 def compare(
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
123 repo,
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
124 local_case,
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
125 remote_case,
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
126 display_header=True,
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
127 display_case=True,
49460
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
128 ):
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
129 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
130 if display_header:
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
131 pieces = ['#']
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
132 if display_case:
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
133 pieces += [
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
134 "repo",
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
135 "local-subset",
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
136 "remote-subset",
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
137 ]
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
138
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
139 pieces += [
49460
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
140 "discovery-variant",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
141 "roundtrips",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
142 "queries",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
143 "revs",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
144 "local-heads",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
145 "common-heads",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
146 "undecided-initial",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
147 "undecided-common",
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
148 "undecided-missing",
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
149 ]
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
150 print(*pieces)
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
151 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
152 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
153 revs = res["nb-revs"]
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
154 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
155 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
156 roundtrips = res["total-roundtrips"]
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
157 queries = res["total-queries"]
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
158 pieces = []
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
159 if display_case:
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
160 pieces += [
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
161 repo,
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
162 format_case(local_case),
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
163 format_case(remote_case),
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
164 ]
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
165 pieces += [
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
166 variant,
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
167 roundtrips,
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
168 queries,
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
169 revs,
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
170 local_heads,
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
171 common_heads,
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
172 ]
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
173 if 'tree-discovery' not in variant:
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
174 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
175 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
176 undecided = undecided_common + undecided_missing
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
177 pieces += [
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
178 undecided,
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
179 undecided_common,
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
180 undecided_missing,
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
181 ]
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
182 print(*pieces)
49018
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
183 return 0
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
184
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
185
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
186 def process(case, variant):
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
187 (repo, left, right) = case
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
188 cmd = list(CMD_BASE)
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
189 cmd.append('-R')
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
190 cmd.append(repo)
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
191 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
192 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
193 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
194 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
195 cmd.extend(variant)
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
196 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
197 out, err = s.communicate()
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
198 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
199
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
200
a78c45a22ce4 perf-util: add a `compare-discovery-case` script
Pierre-Yves David <pierre-yves.david@octobus.net>
parents:
diff changeset
201 if __name__ == '__main__':
49459
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
202
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
203 argv = sys.argv[:]
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
204
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
205 kwargs = {}
49460
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
206 # primitive arg parsing
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
207 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
208 kwargs['display_header'] = False
3c026138f234 compare-disco: display a header by default
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49459
diff changeset
209 argv = [a for a in argv if a != '--no-header']
49461
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
210 if '--no-case' in argv:
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
211 kwargs['display_case'] = False
ebbaf6a77807 compare-disco: add an option to skip the case
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49460
diff changeset
212 argv = [a for a in argv if a != '--no-case']
49459
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
213
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
214 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
215 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
216 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
217 sys.exit(128)
49459
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
218 repo = argv[1]
49462
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
219 local_case = parse_case(argv[2])
ef0b0f94d2e5 compare-disco: move case parsing into its own function
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49461
diff changeset
220 remote_case = parse_case(argv[3])
49459
df1d4e442c08 compare-disco: prepare for primitive argument parsing
Pierre-Yves DAVID <pierre-yves.david@octobus.net>
parents: 49018
diff changeset
221 sys.exit(compare(repo, local_case, remote_case, **kwargs))