Here’s a sample I wrote and find very useful for quick performance tests of python functions.

Python [Show Plain Code]:
  1. import timing
  2. from datetime import datetime
  3. def timeit(fn):
  4.     def wrapper(*args, *kw):
  5.         timing.start()
  6.         fn(*args, **kw)
  7.         timing.finish()
  8.         f = open("timing.csv", "a")
  9.         f.write("%s,%s,%d\n"%(datetime.now(), fn.__name__, timing.micro()))
  10.         f.flush()
  11.         f.close()
  12.     return wrapper

You can then import it to OpenOffice Calculator or MS Excel and do some fancy charts or whatever ;)
Note that this function is using disk I/O so by itself it is also causing some overhead (especially for functions called multiple times per second).
Obviously it’s not thread safe.