Join our newsletter for the latest updates.

Python Program to Measure the Elapsed Time in Python

In this example, you will learn to measure the elapsed time.

To understand this example, you should have the knowledge of the following Python programming topics:


Example 1: Using time module

import time

start = time.time()

print(23*2.3)

end = time.time()
print(end - start)

Output

52.9
3.600120544433594e-05

The execution time depends on the system.


Example 2: Using timeit module

from timeit import default_timer as timer

start = timer()

print(23*2.3)

end = timer()
print(end - start)

Output

52.9
6.355400000000039e-05

timeit provides the most accurate results.

Did you find this article helpful?