#Python time execution
import time
start_time = time.time()
print("Hello") # Hello
end_time = time.time()
total_time = end_time - start_time
print("Time: ", total_time)
#its tricky and so much easy
#python execute time counter
#coded by Luban
import time
start_time = time.time()
while True:
x = time.time() - start_time
x = int(x)
print('Current Time = ',str(x))
# python code execution time -- using wrapper
import time
def exec_time(func):
def wrapper():
start_time = time.time()
result = func()
elapsed = time.time() - start_time
return elapsed, result
return wrapper
@exec_time
def hlw():
time.sleep(2)
return "hello"
t, o = hlw()
print(t, o) # 2.001209020614624 'hello'