import timeit start = timeit.timeit() print("hello") end = timeit.timeit() print(end - start)
from timeit import default_timer as timer start = timer() # ... end = timer() print(end - start) # Time in seconds, e.g. 5.38091952400282