Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WindEnergyToolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wtlib
WindEnergyToolbox
Commits
c782e8f1
Commit
c782e8f1
authored
9 years ago
by
mads
Browse files
Options
Downloads
Patches
Plain Diff
time.clock -> time.time
parent
fd9b96a1
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
wetb/utils/tests/test_caching.py
+2
-0
2 additions, 0 deletions
wetb/utils/tests/test_caching.py
wetb/utils/timing.py
+5
-5
5 additions, 5 deletions
wetb/utils/timing.py
with
7 additions
and
5 deletions
wetb/utils/tests/test_caching.py
+
2
−
0
View file @
c782e8f1
...
@@ -10,6 +10,7 @@ import unittest
...
@@ -10,6 +10,7 @@ import unittest
from
wetb.utils.timing
import
get_time
from
wetb.utils.timing
import
get_time
from
wetb.utils.caching
import
cache_function
,
set_cache_property
from
wetb.utils.caching
import
cache_function
,
set_cache_property
import
pdb
class
Example
(
object
):
class
Example
(
object
):
...
@@ -54,6 +55,7 @@ class TestCacheProperty(unittest.TestCase):
...
@@ -54,6 +55,7 @@ class TestCacheProperty(unittest.TestCase):
def
test_cache_function
(
self
):
def
test_cache_function
(
self
):
#pdb.set_trace()
e
=
Example
()
e
=
Example
()
self
.
assertAlmostEqual
(
get_time
(
e
.
test_cache_function
)()[
1
],
1
,
places
=
2
)
self
.
assertAlmostEqual
(
get_time
(
e
.
test_cache_function
)()[
1
],
1
,
places
=
2
)
self
.
assertAlmostEqual
(
get_time
(
e
.
test_cache_function
)()[
1
],
0
,
places
=
2
)
self
.
assertAlmostEqual
(
get_time
(
e
.
test_cache_function
)()[
1
],
0
,
places
=
2
)
...
...
This diff is collapsed.
Click to expand it.
wetb/utils/timing.py
+
5
−
5
View file @
c782e8f1
...
@@ -14,9 +14,9 @@ def get_time(f):
...
@@ -14,9 +14,9 @@ def get_time(f):
(
'
end
'
,
0.999833492421551
)
(
'
end
'
,
0.999833492421551
)
"""
"""
def
wrap
(
*
args
,
**
kwargs
):
def
wrap
(
*
args
,
**
kwargs
):
t
=
time
.
clock
()
t
=
time
.
time
()
res
=
f
(
*
args
,
**
kwargs
)
res
=
f
(
*
args
,
**
kwargs
)
return
res
,
time
.
clock
()
-
t
return
res
,
time
.
time
()
-
t
w
=
wrap
w
=
wrap
w
.
__name__
=
f
.
__name__
w
.
__name__
=
f
.
__name__
return
w
return
w
...
@@ -103,14 +103,14 @@ def print_line_time(f):
...
@@ -103,14 +103,14 @@ def print_line_time(f):
lines = inspect.getsourcelines(f)[0][2:]
lines = inspect.getsourcelines(f)[0][2:]
tcum = time.
clock
()
tcum = time.
time
()
locals = kwargs
locals = kwargs
gl = f.__globals__
gl = f.__globals__
for l in lines:
for l in lines:
tline = time.
clock
()
tline = time.
time
()
exec(l.strip(), locals, gl) #res = f(*args, **kwargs)
exec(l.strip(), locals, gl) #res = f(*args, **kwargs)
print (
"
%
.
3
fs
\
t
%
.
3
fs
\
t
%
s
"
% (time.
clock
() - tline, time.
clock
() - tcum, l.strip()))
print (
"
%
.
3
fs
\
t
%
.
3
fs
\
t
%
s
"
% (time.
time
() - tline, time.
time
() - tcum, l.strip()))
w = wrap
w = wrap
w.__name__ = f.__name__
w.__name__ = f.__name__
return w
return w
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment