annotate common/time.py @ 361:f45456cdfb87

Added common.misc.homedir()
author Joseph Turian <turian@iro.umontreal.ca>
date Wed, 02 Jul 2008 23:56:51 -0400
parents 430c9e92cd23
children
rev   line source
355
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
1
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
2 import time
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
3 #http://www.daniweb.com/code/snippet368.html
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
4 def print_timing(func):
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
5 def wrapper(*arg):
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
6 t1 = time.time()
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
7 res = func(*arg)
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
8 t2 = time.time()
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
9 print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
10 return res
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
11 return wrapper
430c9e92cd23 Added common directory
Joseph Turian <turian@iro.umontreal.ca>
parents:
diff changeset
12