python how to measure code run in time

import time
start_time = time.time()
main()
print("--- %s seconds ---" % (time.time() - start_time))

Here is what the above code is Doing:
1. It’s creating a list of all the possible permutations of the numbers 1-9.
2. It’s creating a list of all the possible permutations of the numbers 1-9, but it’s only keeping the permutations that are pandigital.
3. It’s creating a list of all the possible permutations of the numbers 1-9, but it’s only keeping the permutations that are pandigital and have a sub-string divisibility property.
4. It’s creating a list of all the possible permutations of the numbers 1-9, but it’s only keeping the permutations that are pandigital and have a sub-string divisibility property. It’s also summing up all the permutations that it’s keeping.

The first step takes about 0.1 seconds. The second step takes about 0.1 seconds. The third step takes about 0.1 seconds. The fourth step takes about 0.1 seconds.

So the total runtime is about 0.4 seconds.