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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -