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,11 +557,13 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() | |
|
560 | with context(): | |||
554 | func() |
|
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() | |
|
566 | with context(): | |||
559 | with profiler: |
|
567 | with profiler: | |
560 | with timeone() as item: |
|
568 | with timeone() as item: | |
561 | r = func() |
|
569 | r = func() |
General Comments 0
You need to be logged in to leave comments.
Login now