Get Delta/Elapse time in Python

How to get delta time in python? Python provide time module, as my favourite way to get delta / elapse time, of course, depends on what you need, to get simple hour-minute-seconds is what i usually do taking user normal actions, like time taken running scripts, batching, clicking buttons and navigate between tabs, or buttons.

[python]
import time

startTime = time.time()

# doing blah… blah…
# whatever actions we do in here

elapsedTime = time.gmtime(time.time() – startTime)
strTime = time.strftime("%H:%M:%S", elapsedTime)
print "action taken in %s" % strTime
[/python]

Do you have a second?

Human usually only care about hour-minute-seconds, because it’s how we communicate right?
People use second to measure time, at least. “How long does it takes to backup?”, “Do you have a second?”, we talk in second, the smallest notion of time in daily human communication.

Pyhton time module works well for this purpose.

One thought on “Get Delta/Elapse time in Python

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s