Show More
@@ -178,6 +178,9 b' try:' | |||
|
178 | 178 | configitem('perf', 'parentscount', |
|
179 | 179 | default=mercurial.configitems.dynamicdefault, |
|
180 | 180 | ) |
|
181 | configitem('perf', 'all-timing', | |
|
182 | default=mercurial.configitems.dynamicdefault, | |
|
183 | ) | |
|
181 | 184 | except (ImportError, AttributeError): |
|
182 | 185 | pass |
|
183 | 186 | |
@@ -247,12 +250,15 b' def gettimer(ui, opts=None):' | |||
|
247 | 250 | # experimental config: perf.stub |
|
248 | 251 | if ui.configbool("perf", "stub", False): |
|
249 | 252 | return functools.partial(stub_timer, fm), fm |
|
250 | return functools.partial(_timer, fm), fm | |
|
253 | ||
|
254 | # experimental config: perf.all-timing | |
|
255 | displayall = ui.configbool("perf", "all-timing", False) | |
|
256 | return functools.partial(_timer, fm, displayall=displayall), fm | |
|
251 | 257 | |
|
252 | 258 | def stub_timer(fm, func, title=None): |
|
253 | 259 | func() |
|
254 | 260 | |
|
255 | def _timer(fm, func, title=None): | |
|
261 | def _timer(fm, func, title=None, displayall=False): | |
|
256 | 262 | gc.collect() |
|
257 | 263 | results = [] |
|
258 | 264 | begin = util.timer() |
@@ -277,14 +283,27 b' def _timer(fm, func, title=None):' | |||
|
277 | 283 | fm.write('title', '! %s\n', title) |
|
278 | 284 | if r: |
|
279 | 285 | fm.write('result', '! result: %s\n', r) |
|
280 | m = min(results) | |
|
286 | def display(role, entry): | |
|
287 | prefix = '' | |
|
288 | if role != 'best': | |
|
289 | prefix = '%s.' % role | |
|
281 | 290 | fm.plain('!') |
|
282 |
fm.write('wall', ' wall %f', |
|
|
283 |
fm.write('comb', ' comb %f', |
|
|
284 |
fm.write('user', ' user %f', |
|
|
285 |
fm.write('sys', ' sys %f', |
|
|
286 |
fm.write('count', ' ( |
|
|
291 | fm.write(prefix + 'wall', ' wall %f', entry[0]) | |
|
292 | fm.write(prefix + 'comb', ' comb %f', entry[1] + entry[2]) | |
|
293 | fm.write(prefix + 'user', ' user %f', entry[1]) | |
|
294 | fm.write(prefix + 'sys', ' sys %f', entry[2]) | |
|
295 | fm.write(prefix + 'count', ' (%s of %d)', role, count) | |
|
287 | 296 | fm.plain('\n') |
|
297 | results.sort() | |
|
298 | min_val = results[0] | |
|
299 | display('best', min_val) | |
|
300 | if displayall: | |
|
301 | max_val = results[-1] | |
|
302 | display('max', max_val) | |
|
303 | avg = tuple([sum(x) / count for x in zip(*results)]) | |
|
304 | display('avg', avg) | |
|
305 | median = results[len(results) // 2] | |
|
306 | display('median', median) | |
|
288 | 307 | |
|
289 | 308 | # utilities for historical portability |
|
290 | 309 |
@@ -176,7 +176,24 b' perfstatus' | |||
|
176 | 176 | $ hg perfwalk |
|
177 | 177 | $ hg perfparents |
|
178 | 178 | |
|
179 | test actual output | |
|
180 | ------------------ | |
|
181 | ||
|
182 | normal output: | |
|
183 | ||
|
184 | $ hg perfheads --config perf.stub=no | |
|
185 | ! wall * comb * user * sys * (best of *) (glob) | |
|
186 | ||
|
187 | detailed output: | |
|
188 | ||
|
189 | $ hg perfheads --config perf.all-timing=yes --config perf.stub=no | |
|
190 | ! wall * comb * user * sys * (best of *) (glob) | |
|
191 | ! wall * comb * user * sys * (max of *) (glob) | |
|
192 | ! wall * comb * user * sys * (avg of *) (glob) | |
|
193 | ! wall * comb * user * sys * (median of *) (glob) | |
|
194 | ||
|
179 | 195 | Check perf.py for historical portability |
|
196 | ---------------------------------------- | |
|
180 | 197 | |
|
181 | 198 | $ cd "$TESTDIR/.." |
|
182 | 199 |
General Comments 0
You need to be logged in to leave comments.
Login now