diff misc.py @ 231:38beb81f4e8b

Automated merge with ssh://projects@lgcm.iro.umontreal.ca/hg/pylearn
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 27 May 2008 13:46:03 -0400
parents d7250ee86f72
children 9e96fe8b955c
line wrap: on
line diff
--- a/misc.py	Tue May 27 13:23:05 2008 -0400
+++ b/misc.py	Tue May 27 13:46:03 2008 -0400
@@ -27,3 +27,13 @@
     This should run in O(n1+n2) where n1=|list1|, n2=|list2|.
     """
     return list(set.intersection(set(list1),set(list2)))
+import time
+#http://www.daniweb.com/code/snippet368.html
+def print_timing(func):
+    def wrapper(*arg):
+        t1 = time.time()
+        res = func(*arg)
+        t2 = time.time()
+        print '%s took %0.3f ms' % (func.func_name, (t2-t1)*1000.0)
+        return res
+    return wrapper