##// END OF EJS Templates
revsetbenchmarks: allow running multiple variants per revset...
Pierre-Yves David -
r25540:f08ad5d1 default
parent child Browse files
Show More
@@ -16,6 +16,8 b' from subprocess import check_call, Popen'
16 # cannot use argparse, python 2.7 only
16 # cannot use argparse, python 2.7 only
17 from optparse import OptionParser
17 from optparse import OptionParser
18
18
19 DEFAULTVARIANTS = ['plain']
20
19 def check_output(*args, **kwargs):
21 def check_output(*args, **kwargs):
20 kwargs.setdefault('stderr', PIPE)
22 kwargs.setdefault('stderr', PIPE)
21 kwargs.setdefault('stdout', PIPE)
23 kwargs.setdefault('stdout', PIPE)
@@ -144,32 +146,37 b' def formatfactor(factor):'
144 return 'x%ix%i' % (factor, order)
146 return 'x%ix%i' % (factor, order)
145
147
146 _marker = object()
148 _marker = object()
147 def printresult(idx, data, maxidx, verbose=False, reference=_marker):
149 def printresult(variants, idx, data, maxidx, verbose=False, reference=_marker):
148 """print a line of result to stdout"""
150 """print a line of result to stdout"""
149 mask = '%%0%ii) %%s' % idxwidth(maxidx)
151 mask = '%%0%ii) %%s' % idxwidth(maxidx)
150 out = ['%10.6f' % data['wall']]
152 out = []
151 if reference is not _marker:
153 for var in variants:
152 factor = None
154 out.append('%10.6f' % data[var]['wall'])
153 if reference is not None:
155 if reference is not _marker:
154 factor = getfactor(reference, data, 'wall')
156 factor = None
155 out.append(formatfactor(factor))
157 if reference is not None:
156 if verbose:
158 factor = getfactor(reference[var], data[var], 'wall')
157 out.append('%10.6f' % data['comb'])
159 out.append(formatfactor(factor))
158 out.append('%10.6f' % data['user'])
160 if verbose:
159 out.append('%10.6f' % data['sys'])
161 out.append('%10.6f' % data[var]['comb'])
160 out.append('%6d' % data['count'])
162 out.append('%10.6f' % data[var]['user'])
163 out.append('%10.6f' % data[var]['sys'])
164 out.append('%6d' % data[var]['count'])
161 print mask % (idx, ' '.join(out))
165 print mask % (idx, ' '.join(out))
162
166
163 def printheader(maxidx, verbose=False, relative=False):
167 def printheader(variants, maxidx, verbose=False, relative=False):
164 header = [' ' * (idxwidth(maxidx) + 1),
168 header = [' ' * (idxwidth(maxidx) + 1)]
165 ' %-8s' % 'time']
169 for var in variants:
166 if relative:
170 if not var:
167 header.append(' ')
171 var = 'iter'
168 if verbose:
172 header.append(' %-8s' % var)
169 header.append(' %-8s' % 'comb')
173 if relative:
170 header.append(' %-8s' % 'user')
174 header.append(' ')
171 header.append(' %-8s' % 'sys')
175 if verbose:
172 header.append('%6s' % 'count')
176 header.append(' %-8s' % 'comb')
177 header.append(' %-8s' % 'user')
178 header.append(' %-8s' % 'sys')
179 header.append('%6s' % 'count')
173 print ' '.join(header)
180 print ' '.join(header)
174
181
175 def getrevs(spec):
182 def getrevs(spec):
@@ -182,6 +189,12 b' def getrevs(spec):'
182 return [r for r in out.split() if r]
189 return [r for r in out.split() if r]
183
190
184
191
192 def applyvariants(revset, variant):
193 if variant == 'plain':
194 return revset
195 return '%s(%s)' % (variant, revset)
196
197
185 parser = OptionParser(usage="usage: %prog [options] <revs>")
198 parser = OptionParser(usage="usage: %prog [options] <revs>")
186 parser.add_option("-f", "--file",
199 parser.add_option("-f", "--file",
187 help="read revset from FILE (stdin if omitted)",
200 help="read revset from FILE (stdin if omitted)",
@@ -193,6 +206,11 b' parser.add_option("-v", "--verbose",'
193 action='store_true',
206 action='store_true',
194 help="display all timing data (not just best total time)")
207 help="display all timing data (not just best total time)")
195
208
209 parser.add_option("", "--variants",
210 default=','.join(DEFAULTVARIANTS),
211 help="comma separated list of variant to test "
212 "(eg: plain,min,sorted) (plain = no modification)")
213
196 (options, args) = parser.parse_args()
214 (options, args) = parser.parse_args()
197
215
198 if not args:
216 if not args:
@@ -221,6 +239,8 b' revs = []'
221 for a in args:
239 for a in args:
222 revs.extend(getrevs(a))
240 revs.extend(getrevs(a))
223
241
242 variants = options.variants.split(',')
243
224 results = []
244 results = []
225 for r in revs:
245 for r in revs:
226 print "----------------------------"
246 print "----------------------------"
@@ -229,11 +249,16 b' for r in revs:'
229 update(r)
249 update(r)
230 res = []
250 res = []
231 results.append(res)
251 results.append(res)
232 printheader(len(revsets), verbose=options.verbose)
252 printheader(variants, len(revsets), verbose=options.verbose)
233 for idx, rset in enumerate(revsets):
253 for idx, rset in enumerate(revsets):
234 data = perf(rset, target=options.repo)
254 varres = {}
235 res.append(data)
255 for var in variants:
236 printresult(idx, data, len(revsets), verbose=options.verbose)
256 varrset = applyvariants(rset, var)
257 data = perf(varrset, target=options.repo)
258 varres[var] = data
259 res.append(varres)
260 printresult(variants, idx, varres, len(revsets),
261 verbose=options.verbose)
237 sys.stdout.flush()
262 sys.stdout.flush()
238 print "----------------------------"
263 print "----------------------------"
239
264
@@ -256,10 +281,10 b' print'
256 for ridx, rset in enumerate(revsets):
281 for ridx, rset in enumerate(revsets):
257
282
258 print "revset #%i: %s" % (ridx, rset)
283 print "revset #%i: %s" % (ridx, rset)
259 printheader(len(results), verbose=options.verbose, relative=True)
284 printheader(variants, len(results), verbose=options.verbose, relative=True)
260 ref = None
285 ref = None
261 for idx, data in enumerate(results):
286 for idx, data in enumerate(results):
262 printresult(idx, data[ridx], len(results), verbose=options.verbose,
287 printresult(variants, idx, data[ridx], len(results),
263 reference=ref)
288 verbose=options.verbose, reference=ref)
264 ref = data[ridx]
289 ref = data[ridx]
265 print
290 print
General Comments 0
You need to be logged in to leave comments. Login now