# Program to find the execution time of a program in Python

In this instructional exercise, we will figure out how to discover the execution time of a basic program that will compute the factorial of a huge number in the Python programming language?

The execution time of a program is characterized as the time spent by the framework to execute the undertaking. As we as a whole realize any program takes some execution time however we don’t have the foggiest idea how much. Along these lines, don’t stress, in this instructional exercise we will learn it by utilizing the datetime module and furthermore we will see the execution time for finding the factorial of a huge number. An enormous number will be given by the client and we need to compute the factorial of a number, likewise, we need to discover the execution time of the factorial program. Before going to compose the Python program, we will attempt to comprehend the calculation.

The calculation to discover the execution time of a factorial program:

• At first, we will import the datetime module and furthermore the math module(to locate the factorial) in the Program. Take the estimation of a number N from the client.
• Take the estimation of a number N from the client.
• Locate the underlying time by utilizing presently() work and dole out it to a variable which is t_start.
• Compute the factorial of a given number(N) and print it.
• Here, we will likewise locate the present time and allot it to a variable which is t_end.
• To realize the execution time basically discover the distinction between the t_end and t_start i.e t_end – t_start.

Presently, how about we start composing the Python program by just executing the above calculation.

``````# importing the modules
from datetime import datetime
import math

N=int(input("Enter the value of N: "))

t_start=datetime.now()
s=math.factorial(N)

print("factorial of the number:",s)

t_end=datetime.now()
e=t_end-t_start
print("The execution time for factorial program: ",e)
``````

### Output:

``````Enter the value of N: 25
factorial of the number: 15511210043330985984000000
The execution time for factorial program: 0:00:00.000022``````

The yield arrangement of the execution time of factorial as “hours: minutes: seconds. microseconds“.