How to get the Execution Time of A Python Program

In order to get the execution time of a Python program, you can make use of the time() function from the time module.

time.time() returns the time in seconds since the epoch as a floating point number.


import time

program_start_time = time.time()

def func1():
  print("func 1 called!")

def func2():
  print("func 2 called!")

def func3():
  print("func 3 called!")


program_end_time = time.time()

print("The Program took ", program_end_time - program_start_time," seconds to run!")
func 1 called!
func 2 called!
func 3 called!
The program took  0.0028166770935058594  seconds to run!
Get Execution Time of a Python Program

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail:

Copyright ยฉ Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap