101 nbidx //= 10 |
101 nbidx //= 10 |
102 if not idxwidth: |
102 if not idxwidth: |
103 idxwidth = 1 |
103 idxwidth = 1 |
104 return idxwidth |
104 return idxwidth |
105 |
105 |
106 def printresult(idx, data, maxidx): |
106 def printresult(idx, data, maxidx, verbose=False): |
107 """print a line of result to stdout""" |
107 """print a line of result to stdout""" |
108 mask = '%%0%ii) %%s' % idxwidth(maxidx) |
108 mask = '%%0%ii) %%s' % idxwidth(maxidx) |
109 out = ['%10.6f' % data['wall'], |
109 out = ['%10.6f' % data['wall']] |
110 '%10.6f' % data['comb'], |
110 if verbose: |
111 '%10.6f' % data['user'], |
111 out.append('%10.6f' % data['comb']) |
112 '%10.6f' % data['sys'], |
112 out.append('%10.6f' % data['user']) |
113 '%6d' % data['count'], |
113 out.append('%10.6f' % data['sys']) |
114 ] |
114 out.append('%6d' % data['count']) |
115 print mask % (idx, ' '.join(out)) |
115 print mask % (idx, ' '.join(out)) |
116 |
116 |
117 def printheader(maxidx): |
117 def printheader(maxidx, verbose=False): |
118 header = [' ' * (idxwidth(maxidx) + 1), |
118 header = [' ' * (idxwidth(maxidx) + 1), |
119 ' %-8s' % 'wall', |
119 ' %-8s' % 'time'] |
120 ' %-8s' % 'comb', |
120 if verbose: |
121 ' %-8s' % 'user', |
121 header.append(' %-8s' % 'comb') |
122 ' %-8s' % 'sys', |
122 header.append(' %-8s' % 'user') |
123 '%6s' % 'count', |
123 header.append(' %-8s' % 'sys') |
124 ] |
124 header.append('%6s' % 'count') |
125 print ' '.join(header) |
125 print ' '.join(header) |
126 |
126 |
127 def getrevs(spec): |
127 def getrevs(spec): |
128 """get the list of rev matched by a revset""" |
128 """get the list of rev matched by a revset""" |
129 try: |
129 try: |
139 help="read revset from FILE (stdin if omitted)", |
139 help="read revset from FILE (stdin if omitted)", |
140 metavar="FILE") |
140 metavar="FILE") |
141 parser.add_option("-R", "--repo", |
141 parser.add_option("-R", "--repo", |
142 help="run benchmark on REPO", metavar="REPO") |
142 help="run benchmark on REPO", metavar="REPO") |
143 |
143 |
|
144 parser.add_option("-v", "--verbose", |
|
145 action='store_true', |
|
146 help="display all timing data (not just best total time)") |
|
147 |
144 (options, args) = parser.parse_args() |
148 (options, args) = parser.parse_args() |
145 |
149 |
146 if not args: |
150 if not args: |
147 parser.print_help() |
151 parser.print_help() |
148 sys.exit(255) |
152 sys.exit(255) |
175 printrevision(r) |
179 printrevision(r) |
176 print "----------------------------" |
180 print "----------------------------" |
177 update(r) |
181 update(r) |
178 res = [] |
182 res = [] |
179 results.append(res) |
183 results.append(res) |
180 printheader(len(revsets)) |
184 printheader(len(revsets), verbose=options.verbose) |
181 for idx, rset in enumerate(revsets): |
185 for idx, rset in enumerate(revsets): |
182 data = perf(rset, target=options.repo) |
186 data = perf(rset, target=options.repo) |
183 res.append(data) |
187 res.append(data) |
184 printresult(idx, data, len(revsets)) |
188 printresult(idx, data, len(revsets), verbose=options.verbose) |
185 sys.stdout.flush() |
189 sys.stdout.flush() |
186 print "----------------------------" |
190 print "----------------------------" |
187 |
191 |
188 |
192 |
189 print """ |
193 print """ |
202 print |
206 print |
203 |
207 |
204 for ridx, rset in enumerate(revsets): |
208 for ridx, rset in enumerate(revsets): |
205 |
209 |
206 print "revset #%i: %s" % (ridx, rset) |
210 print "revset #%i: %s" % (ridx, rset) |
207 printheader(len(results)) |
211 printheader(len(results), verbose=options.verbose) |
208 for idx, data in enumerate(results): |
212 for idx, data in enumerate(results): |
209 printresult(idx, data[ridx], len(results)) |
213 printresult(idx, data[ridx], len(results), verbose=options.verbose) |
210 print |
214 print |