##// END OF EJS Templates
perf: add a new "context" argument to timer...
marmoute -
r51569:28620be8 default
parent child Browse files
Show More
@@ -532,10 +532,16 b' DEFAULTLIMITS = ('
532 )
532 )
533
533
534
534
535 @contextlib.contextmanager
536 def noop_context():
537 yield
538
539
535 def _timer(
540 def _timer(
536 fm,
541 fm,
537 func,
542 func,
538 setup=None,
543 setup=None,
544 context=noop_context,
539 title=None,
545 title=None,
540 displayall=False,
546 displayall=False,
541 limits=DEFAULTLIMITS,
547 limits=DEFAULTLIMITS,
@@ -551,14 +557,16 b' def _timer('
551 for i in range(prerun):
557 for i in range(prerun):
552 if setup is not None:
558 if setup is not None:
553 setup()
559 setup()
554 func()
560 with context():
561 func()
555 keepgoing = True
562 keepgoing = True
556 while keepgoing:
563 while keepgoing:
557 if setup is not None:
564 if setup is not None:
558 setup()
565 setup()
559 with profiler:
566 with context():
560 with timeone() as item:
567 with profiler:
561 r = func()
568 with timeone() as item:
569 r = func()
562 profiler = NOOPCTX
570 profiler = NOOPCTX
563 count += 1
571 count += 1
564 results.append(item[0])
572 results.append(item[0])
General Comments 0
You need to be logged in to leave comments. Login now