MCPcopy
hub / github.com/marshmallow-code/marshmallow / run_timeit

Function run_timeit

performance/benchmark.py:85–104  ·  view source on GitHub ↗
(quotes, iterations, repeat, *, profile=False)

Source from the content-addressed store, hash-verified

83
84
85def 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
107def main():

Callers 1

mainFunction · 0.85

Calls 2

dumpMethod · 0.80
QuoteSchemaClass · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…