Here’s an answer to the same question you’re asking: https://stackoverflow.com/a/2866456/4380308
import time
t0 = time.time()
code_block
t1 = time.time()
total = t1-t0
Or you can use the ‘timeit’ module: https://stackoverflow.com/a/2866460/4380308
timeit.timeit('foobar()', number=1000)