diff --git a/wetb/utils/tests/test_caching.py b/wetb/utils/tests/test_caching.py index e4d882e3e408a1d09e472ba243ef123442daca37..28e1b2129cbb6d99f94232b12743253296b1a508 100644 --- a/wetb/utils/tests/test_caching.py +++ b/wetb/utils/tests/test_caching.py @@ -10,6 +10,7 @@ import unittest from wetb.utils.timing import get_time from wetb.utils.caching import cache_function, set_cache_property +import pdb class Example(object): @@ -54,6 +55,7 @@ class TestCacheProperty(unittest.TestCase): def test_cache_function(self): + #pdb.set_trace() e = Example() self.assertAlmostEqual(get_time(e.test_cache_function)()[1], 1, places=2) self.assertAlmostEqual(get_time(e.test_cache_function)()[1], 0, places=2) diff --git a/wetb/utils/timing.py b/wetb/utils/timing.py index f3aea9a345a8725e7e75ffc1f8b3f33c92106679..ab67d8b1c7ec18a9899fd30a07656b894efa0f31 100644 --- a/wetb/utils/timing.py +++ b/wetb/utils/timing.py @@ -14,9 +14,9 @@ def get_time(f): ('end', 0.999833492421551) """ def wrap(*args, **kwargs): - t = time.clock() + t = time.time() res = f(*args, **kwargs) - return res, time.clock() - t + return res, time.time() - t w = wrap w.__name__ = f.__name__ return w @@ -103,14 +103,14 @@ def print_line_time(f): lines = inspect.getsourcelines(f)[0][2:] - tcum = time.clock() + tcum = time.time() locals = kwargs gl = f.__globals__ for l in lines: - tline = time.clock() + tline = time.time() exec(l.strip(), locals, gl) #res = f(*args, **kwargs) - print ("%.3fs\t%.3fs\t%s" % (time.clock() - tline, time.clock() - tcum, l.strip())) + print ("%.3fs\t%.3fs\t%s" % (time.time() - tline, time.time() - tcum, l.strip())) w = wrap w.__name__ = f.__name__ return w