Ben Chuanlong Du's Blog

It is never too late to learn.

Hands on the time Module in Python

The code below returns the execution time in seconds.

In [1]:
import time

start = time.time()
for i in range(1000):
    x = i * i
end = time.time()
print(end - start)
0.0002493858337402344

Comments