How can I measure the execution time of a function in Python?
How can I measure the execution time of a function in Python?
How can I measure the execution time of a function in Python?
solveurit24@gmail.com Changed status to publish February 13, 2025
Use the time module to measure execution time.
import time
def my_function():
# Some code
pass
start_time = time.time()
my_function()
end_time = time.time()
execution_time = end_time - start_time
print(f"Execution time: {execution_time} seconds")solveurit24@gmail.com Changed status to publish February 13, 2025