Counting time taken for programme in python

#Python 3.7.5

import time,math

t=time.clock()

print(math.factorial(5))

t2=time.clock()-t

print("Time taken is ",t2)

NOTE:

From python 3.8 onwards use time.perf_counter()


#Python 3.8

import time,math

t=time.perf_counter()

print(math.factorial(5))

t2=time.perf_counter()-t

print(t2)



Comments

Popular posts from this blog

Solving maze puzzle in python