0
How do I implement a stopwatch into my Python program to see exactly how long it takes to run?
2 Answers
+ 7
import timeit
start_time = timeit.default_timer()
# statements from your program go here
stop_time = timeit.default_timer()
running_time = stop_time - start_time
print ("Program running time: ", running_time)
+ 2
import time
seconds=0
while True:
time.sleep(1)
seconds+=1
print(seconds, end='\r')