Measure script running time in Python

Viewed 17390

I've had this question for a long time, and I have searched for an answer in several places, without success...

My question: How to measure the time that a given script takes to fully complete?

Imagine I had this silly script to calculate the sum of all the numbers from 0 to 10^12:

x = 0
for i in range(pow(10,12)):
    x += i
print(x)

How could I know how much time it took my PC to complete that?

Thanks in advance, RSerrao

3 Answers
Related