1from timer import Timer
2t = Timer()
3t.start()
4# Run stuff here.
5t.stop()
1import time
2
3# starting time
4start = time.time()
5
6# program body starts
7for i in range(10):
8 print(i)
9
10# sleeping for 1 sec to get 10 sec runtime
11time.sleep(1)
12
13# program body ends
14
15# end time
16end = time.time()
17
18# total time taken
19print(f"Runtime of the program is {end - start}")
1import timeit
2import_module = "import random"
3testcode = '''
4def test():
5 return random.randint(10, 100)
6'''
7print(timeit.repeat(stmt=testcode, setup=import_module))
8
1#its tricky and so much easy
2#python execute time counter
3#coded by Luban
4import time
5start_time = time.time()
6while True:
7 x = time.time() - start_time
8 x = int(x)
9 print('Current Time = ',str(x))