time functions python code example
Example 1: python time a funciton
import time
start = time.time()
print("hello")
end = time.time()
print(end - start)
Example 2: python time library
import time
now = time.time()
print(now)
Example 3: time module in python
import time
seconds = time.time()
print("Seconds since epoch =", seconds)
Example 4: time in python
import time
thistime = time.time()
def CountTime():
while(True):
time.sleep(1)
print(thistime)
CountTime()
Example 5: time a function python
Proper answer to timing a loop over a function multiple times
import timeit
timeit.timeit('func_to_time()',globals=globals(),number=1000)
Example 6: Python Time Module
>>> strptime('Fri Mar 01 23:38:40 2019')
time.struct_time(tm_year=2019, tm_mon=3, tm_mday=1, tm_hour=23, tm_min=38, tm_sec=40, tm_wday=4, tm_yday=60, tm_isdst=-1)