views:

23

answers:

2

It was something like cMessage I think? I can;t remember, could someone help me?

+2  A: 

cProfile ?

To time a function, you can also use a decorator like this one:

from functools import wraps
import time

def timed(f):
    """Time a function."""
    @wraps(f)
    def wrapper(*args, **kwds):
        start = time.clock()
        result = f(*args)
        end = 1000 * (time.clock() - start)
        print '%s: %.3f ms' % (f.func_name, end)
        return result
    return wrapper

And "mark" your fonction by "@timed" like that:

@timed
def toBeTimed():
    pass
RC
That's what it was. Thanks!
Jack
+1  A: 

The excellent free online Python book "Dive Into Python" by Mark Pilgrim has an excellent chapter on timing code execution using the timeit module: http://diveintopython.org/performance_tuning/timeit.html

apalopohapa