(quotes, iterations, repeat, *, profile=False)
| 83 | |
| 84 | |
| 85 | def run_timeit(quotes, iterations, repeat, *, profile=False): |
| 86 | quotes_schema = QuoteSchema(many=True) |
| 87 | if profile: |
| 88 | profile = cProfile.Profile() |
| 89 | profile.enable() |
| 90 | |
| 91 | gc.collect() |
| 92 | best = min( |
| 93 | timeit.repeat( |
| 94 | lambda: quotes_schema.dump(quotes), |
| 95 | "gc.enable()", |
| 96 | number=iterations, |
| 97 | repeat=repeat, |
| 98 | ) |
| 99 | ) |
| 100 | if profile: |
| 101 | profile.disable() |
| 102 | profile.dump_stats("marshmallow.pprof") |
| 103 | |
| 104 | return best * 1e6 / iterations / len(quotes) |
| 105 | |
| 106 | |
| 107 | def main(): |
no test coverage detected
searching dependent graphs…