Show More
@@ -16,6 +16,8 b' from subprocess import check_call, Popen' | |||
|
16 | 16 | # cannot use argparse, python 2.7 only |
|
17 | 17 | from optparse import OptionParser |
|
18 | 18 | |
|
19 | DEFAULTVARIANTS = ['plain'] | |
|
20 | ||
|
19 | 21 | def check_output(*args, **kwargs): |
|
20 | 22 | kwargs.setdefault('stderr', PIPE) |
|
21 | 23 | kwargs.setdefault('stdout', PIPE) |
@@ -144,25 +146,30 b' def formatfactor(factor):' | |||
|
144 | 146 | return 'x%ix%i' % (factor, order) |
|
145 | 147 | |
|
146 | 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 | 150 | """print a line of result to stdout""" |
|
149 | 151 | mask = '%%0%ii) %%s' % idxwidth(maxidx) |
|
150 | out = ['%10.6f' % data['wall']] | |
|
152 | out = [] | |
|
153 | for var in variants: | |
|
154 | out.append('%10.6f' % data[var]['wall']) | |
|
151 | 155 | if reference is not _marker: |
|
152 | 156 | factor = None |
|
153 | 157 | if reference is not None: |
|
154 | factor = getfactor(reference, data, 'wall') | |
|
158 | factor = getfactor(reference[var], data[var], 'wall') | |
|
155 | 159 | out.append(formatfactor(factor)) |
|
156 | 160 | if verbose: |
|
157 | out.append('%10.6f' % data['comb']) | |
|
158 | out.append('%10.6f' % data['user']) | |
|
159 | out.append('%10.6f' % data['sys']) | |
|
160 | out.append('%6d' % data['count']) | |
|
161 | out.append('%10.6f' % data[var]['comb']) | |
|
162 | out.append('%10.6f' % data[var]['user']) | |
|
163 | out.append('%10.6f' % data[var]['sys']) | |
|
164 | out.append('%6d' % data[var]['count']) | |
|
161 | 165 | print mask % (idx, ' '.join(out)) |
|
162 | 166 | |
|
163 | def printheader(maxidx, verbose=False, relative=False): | |
|
164 |
header = [' ' * (idxwidth(maxidx) + 1) |
|
|
165 | ' %-8s' % 'time'] | |
|
167 | def printheader(variants, maxidx, verbose=False, relative=False): | |
|
168 | header = [' ' * (idxwidth(maxidx) + 1)] | |
|
169 | for var in variants: | |
|
170 | if not var: | |
|
171 | var = 'iter' | |
|
172 | header.append(' %-8s' % var) | |
|
166 | 173 | if relative: |
|
167 | 174 | header.append(' ') |
|
168 | 175 | if verbose: |
@@ -182,6 +189,12 b' def getrevs(spec):' | |||
|
182 | 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 | 198 | parser = OptionParser(usage="usage: %prog [options] <revs>") |
|
186 | 199 | parser.add_option("-f", "--file", |
|
187 | 200 | help="read revset from FILE (stdin if omitted)", |
@@ -193,6 +206,11 b' parser.add_option("-v", "--verbose",' | |||
|
193 | 206 | action='store_true', |
|
194 | 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 | 214 | (options, args) = parser.parse_args() |
|
197 | 215 | |
|
198 | 216 | if not args: |
@@ -221,6 +239,8 b' revs = []' | |||
|
221 | 239 | for a in args: |
|
222 | 240 | revs.extend(getrevs(a)) |
|
223 | 241 | |
|
242 | variants = options.variants.split(',') | |
|
243 | ||
|
224 | 244 | results = [] |
|
225 | 245 | for r in revs: |
|
226 | 246 | print "----------------------------" |
@@ -229,11 +249,16 b' for r in revs:' | |||
|
229 | 249 | update(r) |
|
230 | 250 | res = [] |
|
231 | 251 | results.append(res) |
|
232 | printheader(len(revsets), verbose=options.verbose) | |
|
252 | printheader(variants, len(revsets), verbose=options.verbose) | |
|
233 | 253 | for idx, rset in enumerate(revsets): |
|
234 | data = perf(rset, target=options.repo) | |
|
235 | res.append(data) | |
|
236 | printresult(idx, data, len(revsets), verbose=options.verbose) | |
|
254 | varres = {} | |
|
255 | for var in variants: | |
|
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 | 262 | sys.stdout.flush() |
|
238 | 263 | print "----------------------------" |
|
239 | 264 | |
@@ -256,10 +281,10 b' print' | |||
|
256 | 281 | for ridx, rset in enumerate(revsets): |
|
257 | 282 | |
|
258 | 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 | 285 | ref = None |
|
261 | 286 | for idx, data in enumerate(results): |
|
262 |
printresult(idx, data[ridx], len(results), |
|
|
263 | reference=ref) | |
|
287 | printresult(variants, idx, data[ridx], len(results), | |
|
288 | verbose=options.verbose, reference=ref) | |
|
264 | 289 | ref = data[ridx] |
|
265 | 290 |
General Comments 0
You need to be logged in to leave comments.
Login now