Results 1 to 2 of 2

Thread: Python program execution time

  1. #1

    Default 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
    Code:
    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
    Code:
    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

  2. #2
    Join Date
    Jun 2008
    Location
    Germany
    Posts
    301

    Default Re: Python program execution time

    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •