Skip to content

PRO TIP Block youtube.com at the DNS level — Pi-hole, NextDNS or your hosts file — but allow youtube-nocookie.com and i.ytimg.com. These tutorials keep playing; the rabbit hole does not.

Learning without distractions

How to measure EXECUTION TIME in Python ⌚

18.1K views on YouTube

# HOW TO MEASURE EXECUTION TIME IN PYTHON

import time

start_time = time.perf_counter()

# YOUR CODE GOES HERE

end_time = time.perf_counter()

elapsed_time = end_time – start_time

print(f”Elapsed time: {elapsed_time:.1f} seconds”)