performance - Python - Print script running time: each 1 or 10 minute -
i'm running scripts take 10-80 minutes. able print script running time each 1/5/10 minutes ( choose).
for example have script i'm creating tables , inserting data db , want measure time through script.
so lets have printing msgs "table 1 has been created"
, "data inserted table 2"
etc.
between msgs want add like: the script running 1 minutes
the script running 2 minutes
the script running 3 minutes
etc...
someone know best practice ?
thanks in advance !
you can use datetime:
from datetime import datetime #at start of script: start_time = datetime.now() # ... stuff ... # when want print time elapsed far: now_time = datetime.now() print(now_time - start_time)
(of course can reformat printing wish)
Comments
Post a Comment