From c782e8f10c7de96ca82df2d26cf2a70dbadfe11a Mon Sep 17 00:00:00 2001 From: madsmpedersen <m@madsp.dk> Date: Thu, 28 Jan 2016 11:19:33 +0100 Subject: [PATCH] time.clock -> time.time --- wetb/utils/tests/test_caching.py | 2 ++ wetb/utils/timing.py | 10 +++++----- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/wetb/utils/tests/test_caching.py b/wetb/utils/tests/test_caching.py index e4d882e..28e1b21 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 f3aea9a..ab67d8b 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 -- GitLab