0

How do I implement a stopwatch into my Python program to see exactly how long it takes to run?

9th Aug 2017, 11:36 PM
Erik Johanson
Erik Johanson - avatar
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)
10th Aug 2017, 7:14 AM
BĂ ng Tứ Cường
BĂ ng Tứ Cường - avatar
+ 2
import time seconds=0 while True: time.sleep(1) seconds+=1 print(seconds, end='\r')
2nd Aug 2021, 5:08 AM
Sancho Godinho
Sancho Godinho - avatar