Python program execution time

I need to output time taken by various functions in a python program.Have not been able to find an easy enough example on using profilers.Can we use some other way without using profilers,something like clock() in Turbo C.Please give an example regarding both approches as it will be extremely helpful and will solve lots of problems for me

import time
a=time.clock()

for i in range(1,100):
	for j in range(1,100):
		print i*j
b=time.clock()
print b
print a
import time
a=time.time()

for i in range(1,100):
	for j in range(1,100):
		print i*j
b=time.time()
print b
print a

These two dont seem to me as perfect.Multiplication happens faster than addition

Hi,

there are some modules that provides profiler functionality. Just have a look at 27.4. The Python Profilers — Python v2.6.2 documentation

Hope this helps