Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
PyWake
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
TOPFARM
PyWake
Commits
ae200e20
Commit
ae200e20
authored
3 years ago
by
Mads M. Pedersen
Browse files
Options
Downloads
Patches
Plain Diff
Reduce memory consumption of All2AllIterative with NOJDeficit + add test of...
parent
cedd3f6f
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
py_wake/tests/test_wind_farm_models/test_memory_usage.py
+61
-0
61 additions, 0 deletions
py_wake/tests/test_wind_farm_models/test_memory_usage.py
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
62 additions
and
0 deletions
py_wake/tests/test_wind_farm_models/test_memory_usage.py
0 → 100644
+
61
−
0
View file @
ae200e20
from
py_wake.examples.data.hornsrev1
import
V80
,
Hornsrev1Site
,
wt16_x
,
wt16_y
from
py_wake.deficit_models.noj
import
NOJ
,
NOJDeficit
import
os
import
psutil
import
matplotlib.pyplot
as
plt
import
numpy
as
np
import
gc
from
py_wake.wind_farm_models.engineering_models
import
All2AllIterative
import
memory_profiler
from
py_wake.tests
import
npt
import
pytest
def
get_memory_usage
():
pid
=
os
.
getpid
()
python_process
=
psutil
.
Process
(
pid
)
return
python_process
.
memory_info
()[
0
]
/
1024
**
2
def
test_memory_usage
():
if
os
.
name
==
'
posix
'
:
pytest
.
skip
(
'
Memory usage seems not to work on linux
'
)
gc
.
collect
()
initial_mem_usage
=
get_memory_usage
()
wt
=
V80
()
site
=
Hornsrev1Site
()
x
,
y
=
site
.
initial_position
.
T
for
wfm
,
mem_min
,
mem_max
in
[(
NOJ
(
site
,
wt
),
65
,
90
),
(
All2AllIterative
(
site
,
wt
,
wake_deficitModel
=
NOJDeficit
()),
530
,
540
)]:
mem_usage
,
_
=
memory_profiler
.
memory_usage
(
(
wfm
,
(
x
,
y
),
{
'
wd
'
:
np
.
arange
(
0
,
360
,
4
)}),
interval
=
0.001
,
max_usage
=
True
,
retval
=
True
)
mem_usage
-=
initial_mem_usage
print
(
initial_mem_usage
,
mem_usage
)
assert
mem_min
<
mem_usage
<
mem_max
,
(
initial_mem_usage
,
mem_usage
)
return
def
test_memory_leak
():
N
=
10
wt
=
V80
()
site
=
Hornsrev1Site
()
wfm_lst
=
[
NOJ
(
site
,
wt
),
All2AllIterative
(
site
,
wt
,
wake_deficitModel
=
NOJDeficit
())]
memory_usage
=
np
.
zeros
((
len
(
wfm_lst
),
N
))
for
i
,
wfm
in
enumerate
(
wfm_lst
):
memory_usage
[
i
,
0
]
=
get_memory_usage
()
for
j
in
range
(
1
,
N
):
wfm
(
wt16_x
,
wt16_y
,
ws
=
10
,
wd
=
np
.
arange
(
0
,
360
,
30
))
gc
.
collect
()
memory_usage
[
i
,
j
]
=
get_memory_usage
()
npt
.
assert_array_less
(
memory_usage
-
memory_usage
[:,
:
1
],
1
)
# at most 1mb more than initial usage
if
0
:
for
i
,
wfm
in
enumerate
(
wfm_lst
):
plt
.
plot
(
memory_usage
[
i
],
label
=
str
(
wfm
.
__class__
.
__name__
))
plt
.
legend
()
plt
.
show
()
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
ae200e20
...
...
@@ -57,6 +57,7 @@ setup(name='py_wake',
'
pytest
'
,
# for testing
'
pytest-cov
'
,
# for calculating coverage
'
psutil
'
,
# memory profiling
'
memory_profiler
'
,
# memory profiling
'
sphinx
'
,
# generating documentation
'
sphinx_rtd_theme
'
,
# docs theme
'
line_profiler
'
,
# to check speed
...
...
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