equal
deleted
inserted
replaced
530 (3.0, 100), |
530 (3.0, 100), |
531 (10.0, 3), |
531 (10.0, 3), |
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, |
542 prerun=0, |
548 prerun=0, |
543 profiler=None, |
549 profiler=None, |
549 if profiler is None: |
555 if profiler is None: |
550 profiler = NOOPCTX |
556 profiler = NOOPCTX |
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]) |
565 cstop = util.timer() |
573 cstop = util.timer() |
566 # Look for a stop condition. |
574 # Look for a stop condition. |