Originally posted by psbasha
Getting time from the system
Collapse
X
-
Here's an alternate method:Originally posted by psbashaThanks Barton,
This is what I am looking for.
I need this functionality for finding out ,how much time my application is taking for execution.Based on the more time taken I have to find out which function is taking more time ( similar to profiling).
-PSBCode:from time import sleep import time def formatSec(seconds): milli = int(seconds%1*1000) days = float(seconds)/86400 hours = days%1*24 minutes = hours%1*60 seconds = minutes%1*60 if int(days) > 0: outStr = '%d days,' % days else: outStr = '' outStr = ''.join([outStr, '%02d:%02d:%02d' % (hours, minutes, seconds)]) if milli > 0: outStr += ' and %d milliseconds' % milli return outStr if __name__ == '__main__': t1 = time.time() time.sleep(3.75) t2 = time.time() print formatSec(t2-t1) # >>> 00:00:03 and 750 millisecondsComment
Comment