summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Th?nault <sylvain.thenault@logilab.fr>2010-04-02 09:36:33 +0200
committerSylvain Th?nault <sylvain.thenault@logilab.fr>2010-04-02 09:36:33 +0200
commit468aac4d0baa1e4f480958b4bacb433163a002e8 (patch)
tree04cd7d3a0ae0ef00691f7cd7835902798b814b88
parent036ca82abd2f2b69d3d8bbb7dc50e43192653d4b (diff)
downloadlogilab-common-468aac4d0baa1e4f480958b4bacb433163a002e8.tar.gz
decorators: add time as well as clock to @timed, clock sometimes get negative when function takes too much time to get back
-rw-r--r--decorators.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/decorators.py b/decorators.py
index b656be6..ad5a968 100644
--- a/decorators.py
+++ b/decorators.py
@@ -7,7 +7,7 @@
__docformat__ = "restructuredtext en"
from types import MethodType
-from time import clock
+from time import clock, time
import sys, re
# XXX rewrite so we can use the decorator syntax when keyarg has to be specified
@@ -122,10 +122,11 @@ class iclassmethod(object):
def timed(f):
def wrap(*args, **kwargs):
- t = clock()
- #for i in range(100):
+ t = time()
+ c = clock()
res = f(*args, **kwargs)
- print '%s time: %.9f' % (f.__name__, clock() - t)
+ print '%s clock: %.9f / time: %.9f' % (f.__name__,
+ clock() - c, time() - t)
return res
return wrap