Answers for "how to get runtime of a function in python"

5

python how to measure code run in time

import time
start_time = time.time()
main()
print("--- %s seconds ---" % (time.time() - start_time))
Posted by: Guest on May-09-2020
-1

how to get runtime of a function in python

import datetime
t_set = lambda: datetime.datetime.now().astimezone().replace(microsecond=0)
t_diff = lambda t: str(t_set() - t)
t_stamp = lambda t=None: str(t) if t else str(t_set())
Posted by: Guest on May-22-2021

Code answers related to "how to get runtime of a function in python"

Python Answers by Framework

Browse Popular Code Answers by Language