1import time
2
3start = time.time()
4print("hello")
5end = time.time()
6print(end - start)
1import time
2
3t0 = time.time()
4code_block
5t1 = time.time()
6
7total = t1-t0
1from datetime import datetime
2start = datetime.now()
3# some kind of code
4print(datetime.now() - start)
1from timer import Timer
2t = Timer()
3t.start()
4# Run stuff here.
5t.stop()
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
1import time
2timer_length = float(input("How many seconds would you like you're timer to be set for? "))
3time.sleep(timer_length)
4print("Done!")