##// END OF EJS Templates
perf: allow profiling of more than one run...
marmoute -
r52482:90ef3e04 default
parent child Browse files
Show More
@@ -20,7 +20,10 b' Configurations'
20
20
21 ``profile-benchmark``
21 ``profile-benchmark``
22 Enable profiling for the benchmarked section.
22 Enable profiling for the benchmarked section.
23 (The first iteration is benchmarked)
23 (by default, the first iteration is benchmarked)
24
25 ``profiled-runs``
26 list of iteration to profile (starting from 0)
24
27
25 ``run-limits``
28 ``run-limits``
26 Control the number of runs each benchmark will perform. The option value
29 Control the number of runs each benchmark will perform. The option value
@@ -318,6 +321,11 b' try:'
318 )
321 )
319 configitem(
322 configitem(
320 b'perf',
323 b'perf',
324 b'profiled-runs',
325 default=mercurial.configitems.dynamicdefault,
326 )
327 configitem(
328 b'perf',
321 b'run-limits',
329 b'run-limits',
322 default=mercurial.configitems.dynamicdefault,
330 default=mercurial.configitems.dynamicdefault,
323 experimental=True,
331 experimental=True,
@@ -354,7 +362,7 b' except TypeError:'
354 )
362 )
355 configitem(
363 configitem(
356 b'perf',
364 b'perf',
357 b'profile-benchmark',
365 b'profiled-runs',
358 default=mercurial.configitems.dynamicdefault,
366 default=mercurial.configitems.dynamicdefault,
359 )
367 )
360 configitem(
368 configitem(
@@ -491,9 +499,12 b' def gettimer(ui, opts=None):'
491 limits = DEFAULTLIMITS
499 limits = DEFAULTLIMITS
492
500
493 profiler = None
501 profiler = None
502 profiled_runs = set()
494 if profiling is not None:
503 if profiling is not None:
495 if ui.configbool(b"perf", b"profile-benchmark", False):
504 if ui.configbool(b"perf", b"profile-benchmark", False):
496 profiler = profiling.profile(ui)
505 profiler = lambda: profiling.profile(ui)
506 for run in ui.configlist(b"perf", b"profiled-runs", [0]):
507 profiled_runs.add(int(run))
497
508
498 prerun = getint(ui, b"perf", b"pre-run", 0)
509 prerun = getint(ui, b"perf", b"pre-run", 0)
499 t = functools.partial(
510 t = functools.partial(
@@ -503,6 +514,7 b' def gettimer(ui, opts=None):'
503 limits=limits,
514 limits=limits,
504 prerun=prerun,
515 prerun=prerun,
505 profiler=profiler,
516 profiler=profiler,
517 profiled_runs=profiled_runs,
506 )
518 )
507 return t, fm
519 return t, fm
508
520
@@ -547,13 +559,14 b' def _timer('
547 limits=DEFAULTLIMITS,
559 limits=DEFAULTLIMITS,
548 prerun=0,
560 prerun=0,
549 profiler=None,
561 profiler=None,
562 profiled_runs=(0,),
550 ):
563 ):
551 gc.collect()
564 gc.collect()
552 results = []
565 results = []
553 begin = util.timer()
566 begin = util.timer()
554 count = 0
567 count = 0
555 if profiler is None:
568 if profiler is None:
556 profiler = NOOPCTX
569 profiler = lambda: NOOPCTX
557 for i in range(prerun):
570 for i in range(prerun):
558 if setup is not None:
571 if setup is not None:
559 setup()
572 setup()
@@ -561,13 +574,16 b' def _timer('
561 func()
574 func()
562 keepgoing = True
575 keepgoing = True
563 while keepgoing:
576 while keepgoing:
577 if count in profiled_runs:
578 prof = profiler()
579 else:
580 prof = NOOPCTX
564 if setup is not None:
581 if setup is not None:
565 setup()
582 setup()
566 with context():
583 with context():
567 with profiler:
584 with prof:
568 with timeone() as item:
585 with timeone() as item:
569 r = func()
586 r = func()
570 profiler = NOOPCTX
571 count += 1
587 count += 1
572 results.append(item[0])
588 results.append(item[0])
573 cstop = util.timer()
589 cstop = util.timer()
@@ -59,8 +59,11 b' perfstatus'
59 number of run to perform before starting measurement.
59 number of run to perform before starting measurement.
60
60
61 "profile-benchmark"
61 "profile-benchmark"
62 Enable profiling for the benchmarked section. (The first iteration is
62 Enable profiling for the benchmarked section. (by default, the first
63 benchmarked)
63 iteration is benchmarked)
64
65 "profiled-runs"
66 list of iteration to profile (starting from 0)
64
67
65 "run-limits"
68 "run-limits"
66 Control the number of runs each benchmark will perform. The option value
69 Control the number of runs each benchmark will perform. The option value
General Comments 0
You need to be logged in to leave comments. Login now