##// END OF EJS Templates
perf: add a 'perf.all-timing' option to display more than best time...
Boris Feld -
r38716:55101513 default
parent child Browse files
Show More
@@ -178,6 +178,9 b' try:'
178 configitem('perf', 'parentscount',
178 configitem('perf', 'parentscount',
179 default=mercurial.configitems.dynamicdefault,
179 default=mercurial.configitems.dynamicdefault,
180 )
180 )
181 configitem('perf', 'all-timing',
182 default=mercurial.configitems.dynamicdefault,
183 )
181 except (ImportError, AttributeError):
184 except (ImportError, AttributeError):
182 pass
185 pass
183
186
@@ -247,12 +250,15 b' def gettimer(ui, opts=None):'
247 # experimental config: perf.stub
250 # experimental config: perf.stub
248 if ui.configbool("perf", "stub", False):
251 if ui.configbool("perf", "stub", False):
249 return functools.partial(stub_timer, fm), fm
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 def stub_timer(fm, func, title=None):
258 def stub_timer(fm, func, title=None):
253 func()
259 func()
254
260
255 def _timer(fm, func, title=None):
261 def _timer(fm, func, title=None, displayall=False):
256 gc.collect()
262 gc.collect()
257 results = []
263 results = []
258 begin = util.timer()
264 begin = util.timer()
@@ -277,14 +283,27 b' def _timer(fm, func, title=None):'
277 fm.write('title', '! %s\n', title)
283 fm.write('title', '! %s\n', title)
278 if r:
284 if r:
279 fm.write('result', '! result: %s\n', r)
285 fm.write('result', '! result: %s\n', r)
280 m = min(results)
286 def display(role, entry):
281 fm.plain('!')
287 prefix = ''
282 fm.write('wall', ' wall %f', m[0])
288 if role != 'best':
283 fm.write('comb', ' comb %f', m[1] + m[2])
289 prefix = '%s.' % role
284 fm.write('user', ' user %f', m[1])
290 fm.plain('!')
285 fm.write('sys', ' sys %f', m[2])
291 fm.write(prefix + 'wall', ' wall %f', entry[0])
286 fm.write('count', ' (best of %d)', count)
292 fm.write(prefix + 'comb', ' comb %f', entry[1] + entry[2])
287 fm.plain('\n')
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)
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 # utilities for historical portability
308 # utilities for historical portability
290
309
@@ -176,7 +176,24 b' perfstatus'
176 $ hg perfwalk
176 $ hg perfwalk
177 $ hg perfparents
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 Check perf.py for historical portability
195 Check perf.py for historical portability
196 ----------------------------------------
180
197
181 $ cd "$TESTDIR/.."
198 $ cd "$TESTDIR/.."
182
199
General Comments 0
You need to be logged in to leave comments. Login now