Skip to content
Snippets Groups Projects
Commit c782e8f1 authored by mads's avatar mads
Browse files

time.clock -> time.time

parent fd9b96a1
No related branches found
No related tags found
No related merge requests found
Pipeline #
......@@ -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)
......
......@@ -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
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment