How would I measure passing seconds using Python? | Sololearn: Learn to code for FREE!
+ 1

How would I measure passing seconds using Python?

I want to know how long one of my programs will run!

13th Nov 2016, 4:03 AM
Erik Johanson
Erik Johanson - avatar
2 Antworten
+ 4
try something like this: import time def measure(func, *args): start=time.time() func(*args) return time.time()-start def foo(*args): start, stop=args[0], args[1] for x in range(start, stop): x+=1 print(measure(foo, 0, 10000000)) something like the measure function
13th Nov 2016, 6:15 AM
Burey
Burey - 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