Measure Performance of Python script

Best option

from timeit import default_timer as timer

start = timer()
# ...
end = timer()
print(end - start)  

Simple one

import time

start = time.time()
end = time.time()
print(end - start)

Another one

def foo(): 
    # print "hello"   
    return "hello"

# the easiest way to use timeit is to call it from the command line:

% python -mtimeit -s'import test' ''
1000000 loops, best of 3: 0.254 usec per loop