Measure time of a Python Code

Today we will see how to measure the time of execution of a python code. For this purpose we will be using the timeit module. This module gives simple ways to time small pieces or snippets of Python code.

It is important to know how long your code takes to execute. This can tell you whether you need to reduce execution time or not.

Let us see how to use this.




Another way of doing this is using the time module.



The time is measured in seconds.




Image Courtesy: Wikipedia

Leave a Reply

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

You are commenting using your 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

Powered by

Up ↑

%d bloggers like this: