It was something like cMessage I think? I can;t remember, could someone help me?
views:
23answers:
2
+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
2010-08-09 05:08:21
That's what it was. Thanks!
Jack
2010-08-09 05:08:35
+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
2010-08-09 05:55:15