Best option
from timeit import default_timer as timer
start = timer()
# ...
end = timer()
print(end - start)
Simple one
import time
start = time.time()
print("hello")
end = time.time()
print(end - start)
Another one
https://docs.python.org/3.6/library/timeit.html
def foo():
# print "hello"
return "hello"
# the easiest way to use timeit is to call it from the command line:
% python -mtimeit -s'import test' 'test.foo()'
1000000 loops, best of 3: 0.254 usec per loop