Python: How to time script from beginning to end? -
i've created script processes files , returns size of each file in bytes. time takes dependent on how large directory scan.
at top of script, placed in:
now = "\n", strftime("%y-%m-%d %h:%m:%s", gmtime()) print "started processing data at:",now
and @ bottom:
finish = strftime("%y-%m-%d %h:%m:%s", gmtime()) print "finished processing data at: ", strftime("%y-%m-%d %h:%m:%s", gmtime()) difference = now.strftime("%h:%m:%s", gmtime()) - finish.strftime("%h:%m:%s", gmtime())
i didn't think going work, hope understand logic. want subtract now
hours, minutes & seconds finish
hours, minutes & seconds.
what correct way of doing this?
many thanks.
try datetime module.
from datetime import datetime start = datetime.now()
later
difference = datetime.now() - start
Comments
Post a Comment