timeit.timeit()
timeit.timeit() is a Python function in the Timeit Module category. Times the execution of a small Python code snippet. The syntax is timeit.timeit(stmt="pass", setup="pass", timer=default_timer, number=1000000, globals=None). Returns: Float seconds. A typical example: import timeit
timeit.timeit("x = sum(range(100))", number=10000)
# Time in seconds for 10000 executions. A close sibling is timeit.repeat(), which like timeit() but runs multiple times and returns a list of results. A close sibling is timeit.default_timer(), which default timer for timeit (uses time.perf_counter). A close sibling is timeit.Timer(), which creates a Timer object for repeated timing of code. More about this category: Code timing — timeit, repeat, default_timer. Related Timeit Module entries: timeit.repeat(), timeit.default_timer(), timeit.Timer(). This page is part of the free Python Reference documentation covering 978+ functions, methods, and modules with examples and parameter details. You can try timeit.timeit() immediately in the Python playground, look up unfamiliar terms in the glossary, or return to the Python Reference homepage.