comparison contrib/perf-utils/compare-discovery-case @ 49527:a3356ab610fc stable 6.3rc0

branching: merge default into stable This marks the feature freeze for the 6.3 release
author Rapha?l Gom?s <rgomes@octobus.net>
date Mon, 24 Oct 2022 15:32:14 +0200
parents 5acbc550d987
children 493034cc3265
comparison
equal deleted inserted replaced
49430:192949b68159 49527:a3356ab610fc
95 ] 95 ]
96 96
97 assert set(VARIANTS.keys()) == set(VARIANTS_KEYS) 97 assert set(VARIANTS.keys()) == set(VARIANTS_KEYS)
98 98
99 99
100 def parse_case(case):
101 case_type, case_args = case.split('-', 1)
102 if case_type == 'file':
103 case_args = (case_args,)
104 else:
105 case_args = tuple(int(x) for x in case_args.split('-'))
106 case = (case_type,) + case_args
107 return case
108
109
100 def format_case(case): 110 def format_case(case):
101 return '-'.join(str(s) for s in case) 111 return '-'.join(str(s) for s in case)
102 112
103 113
104 def to_revsets(case): 114 def to_revsets(case):
107 return 'not scratch(all(), %d, "%d")' % (case[1], case[2]) 117 return 'not scratch(all(), %d, "%d")' % (case[1], case[2])
108 elif t == 'randomantichain': 118 elif t == 'randomantichain':
109 return '::randomantichain(all(), "%d")' % case[1] 119 return '::randomantichain(all(), "%d")' % case[1]
110 elif t == 'rev': 120 elif t == 'rev':
111 return '::%d' % case[1] 121 return '::%d' % case[1]
122 elif t == 'file':
123 return '::nodefromfile("%s")' % case[1]
112 else: 124 else:
113 assert False 125 assert False
114 126
115 127
116 def compare(repo, local_case, remote_case): 128 def compare(
129 repo,
130 local_case,
131 remote_case,
132 display_header=True,
133 display_case=True,
134 ):
117 case = (repo, local_case, remote_case) 135 case = (repo, local_case, remote_case)
136 if display_header:
137 pieces = ['#']
138 if display_case:
139 pieces += [
140 "repo",
141 "local-subset",
142 "remote-subset",
143 ]
144
145 pieces += [
146 "discovery-variant",
147 "roundtrips",
148 "queries",
149 "revs",
150 "local-heads",
151 "common-heads",
152 "undecided-initial",
153 "undecided-common",
154 "undecided-missing",
155 ]
156 print(*pieces)
118 for variant in VARIANTS_KEYS: 157 for variant in VARIANTS_KEYS:
119 res = process(case, VARIANTS[variant]) 158 res = process(case, VARIANTS[variant])
120 revs = res["nb-revs"] 159 revs = res["nb-revs"]
121 local_heads = res["nb-head-local"] 160 local_heads = res["nb-head-local"]
122 common_heads = res["nb-common-heads"] 161 common_heads = res["nb-common-heads"]
123 roundtrips = res["total-roundtrips"] 162 roundtrips = res["total-roundtrips"]
124 queries = res["total-queries"] 163 queries = res["total-queries"]
125 if 'tree-discovery' in variant: 164 pieces = []
126 print( 165 if display_case:
166 pieces += [
127 repo, 167 repo,
128 format_case(local_case), 168 format_case(local_case),
129 format_case(remote_case), 169 format_case(remote_case),
130 variant, 170 ]
131 roundtrips, 171 pieces += [
132 queries, 172 variant,
133 revs, 173 roundtrips,
134 local_heads, 174 queries,
135 common_heads, 175 revs,
136 ) 176 local_heads,
137 else: 177 common_heads,
178 ]
179 if 'tree-discovery' not in variant:
138 undecided_common = res["nb-ini_und-common"] 180 undecided_common = res["nb-ini_und-common"]
139 undecided_missing = res["nb-ini_und-missing"] 181 undecided_missing = res["nb-ini_und-missing"]
140 undecided = undecided_common + undecided_missing 182 undecided = undecided_common + undecided_missing
141 print( 183 pieces += [
142 repo,
143 format_case(local_case),
144 format_case(remote_case),
145 variant,
146 roundtrips,
147 queries,
148 revs,
149 local_heads,
150 common_heads,
151 undecided, 184 undecided,
152 undecided_common, 185 undecided_common,
153 undecided_missing, 186 undecided_missing,
154 ) 187 ]
188 print(*pieces)
155 return 0 189 return 0
156 190
157 191
158 def process(case, variant): 192 def process(case, variant):
159 (repo, left, right) = case 193 (repo, left, right) = case
169 out, err = s.communicate() 203 out, err = s.communicate()
170 return json.loads(out)[0] 204 return json.loads(out)[0]
171 205
172 206
173 if __name__ == '__main__': 207 if __name__ == '__main__':
174 if len(sys.argv) != 4: 208
209 argv = sys.argv[:]
210
211 kwargs = {}
212 # primitive arg parsing
213 if '--no-header' in argv:
214 kwargs['display_header'] = False
215 argv = [a for a in argv if a != '--no-header']
216 if '--no-case' in argv:
217 kwargs['display_case'] = False
218 argv = [a for a in argv if a != '--no-case']
219
220 if len(argv) != 4:
175 usage = f'USAGE: {script_name} REPO LOCAL_CASE REMOTE_CASE' 221 usage = f'USAGE: {script_name} REPO LOCAL_CASE REMOTE_CASE'
176 print(usage, file=sys.stderr) 222 print(usage, file=sys.stderr)
177 sys.exit(128) 223 sys.exit(128)
178 repo = sys.argv[1] 224 repo = argv[1]
179 local_case = sys.argv[2].split('-') 225 local_case = parse_case(argv[2])
180 local_case = (local_case[0],) + tuple(int(x) for x in local_case[1:]) 226 remote_case = parse_case(argv[3])
181 remote_case = sys.argv[3].split('-') 227 sys.exit(compare(repo, local_case, remote_case, **kwargs))
182 remote_case = (remote_case[0],) + tuple(int(x) for x in remote_case[1:])
183 sys.exit(compare(repo, local_case, remote_case))