all Python 3timeitfunction
timeit.repeat()
timing
Repeats the timeit() measurement several times and returns a list of times, five by default.
Syntax
timeit.repeat(stmt='pass', setup='pass', timer=default_timer, repeat=5, number=1000000, globals=None) -> list[float]
Take min() of the list, not the mean: larger values come from system noise, not from your code. Each value is the time for number executions, not one, so divide by number to get the time per call. Before Python 3.7 the default was 3 repeats.
Examples
import timeit
times = timeit.repeat('x = 2 ** 10', number=1000)
print(len(times)) # → 5
best = min(times) / 1000
print(best) # → ? секунд на одно выполнение
See also
Open in the full glossarydocs.python.orgReport an inaccuracy