I am trying to count how long a very long process is taking:
import datetime
def main(argv):
starttime = datetime.datetime.now()
for f in somearray:
doSomething(f)
endtime = datetime.datetime.now()
deltatime = endtime-starttime
print "Operation took " + str(deltatime.seconds) + " seconds"
def doSomething(f):
# this takes a looong time (~10 minutes)
In the code above I only end up getting the time elapsed for the last time doSomething
was run. I used to have doSomething
as part of the main
function and the timing was fine, but it made sense to move it to its own function.
I saw this question but it seems to serve a different need.
What am I doing wrong?
Thanks