How to measure the time elapsed of your code execution in Python

Опубликовано: 18 Февраль 2026
на канале: 60 Second How-to
47
2

Subscribe for more
#howto #python #pythonprogramming #pythontutorial #tutorial #1minutevideo #60secondsvideo #fasttutorial #beginners #coding #developer #time

Full Code Snippet

Example 1:
--------------------------
import time

startTime = time.time()

The for loop simulates long running code
print("Start...")
for x in range(30000000):
continue
print("Done!")

endTime = time.time()
totalTime = endTime - startTime

print("Total time to execute code is: ", totalTime)