Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
finam
Manage
Activity
Members
Labels
Plan
Issues
32
Issue boards
Milestones
Code
Merge requests
4
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Monitor
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
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FINAM
finam
Commits
34697323
Commit
34697323
authored
2 years ago
by
Martin Lange
Browse files
Options
Downloads
Patches
Plain Diff
benchmark to_xarray with copy
parent
e611f521
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!227
Benchmark to_xarray with copy
Pipeline
#133673
passed with stages
in 5 minutes and 10 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
benchmarks/data/test_tools.py
+67
-0
67 additions, 0 deletions
benchmarks/data/test_tools.py
with
67 additions
and
0 deletions
benchmarks/data/test_tools.py
+
67
−
0
View file @
34697323
import
datetime
as
dt
import
unittest
import
numpy
as
np
import
pytest
import
finam
as
fm
...
...
@@ -45,6 +46,12 @@ class TestToXarray(unittest.TestCase):
def
setupBenchmark
(
self
,
benchmark
):
self
.
benchmark
=
benchmark
def
copy_xarray_to_xarray
(
self
,
data
,
info
):
return
to_xarray
(
data
.
copy
(),
name
=
"
data
"
,
info
=
info
)
def
copy_numpy_to_xarray
(
self
,
data
,
info
):
return
to_xarray
(
np
.
copy
(
data
),
name
=
"
data
"
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools
"
)
def
test_to_xarray_np_01_2x1
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
...
...
@@ -69,6 +76,38 @@ class TestToXarray(unittest.TestCase):
data
=
strip_data
(
xdata
)
_result
=
self
.
benchmark
(
to_xarray
,
data
=
data
,
name
=
"
test
"
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_np_01_2x1
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
2
,
1
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
data
=
strip_data
(
xdata
)
_result
=
self
.
benchmark
(
self
.
copy_numpy_to_xarray
,
data
=
data
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_np_02_512x256
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
512
,
256
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
data
=
strip_data
(
xdata
)
_result
=
self
.
benchmark
(
self
.
copy_numpy_to_xarray
,
data
=
data
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_np_03_1024x512
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
1024
,
512
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
data
=
strip_data
(
xdata
)
_result
=
self
.
benchmark
(
self
.
copy_numpy_to_xarray
,
data
=
data
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_np_04_2048x1024
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
2048
,
1024
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
data
=
strip_data
(
xdata
)
_result
=
self
.
benchmark
(
self
.
copy_numpy_to_xarray
,
data
=
data
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools
"
)
def
test_to_xarray_xr_01_2x1
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
...
...
@@ -90,6 +129,34 @@ class TestToXarray(unittest.TestCase):
xdata
=
full
(
0.0
,
"
test
"
,
info
)
_result
=
self
.
benchmark
(
to_xarray
,
data
=
xdata
,
name
=
"
test
"
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_xr_01_2x1
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
2
,
1
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
_result
=
self
.
benchmark
(
self
.
copy_xarray_to_xarray
,
data
=
xdata
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_xr_02_512x256
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
512
,
256
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
_result
=
self
.
benchmark
(
self
.
copy_xarray_to_xarray
,
data
=
xdata
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_xr_03_1024x512
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
1024
,
512
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
_result
=
self
.
benchmark
(
self
.
copy_xarray_to_xarray
,
data
=
xdata
,
info
=
info
)
@pytest.mark.benchmark
(
group
=
"
data-tools-slow
"
)
def
test_cp_to_xarray_xr_04_2048x1024
(
self
):
time
=
dt
.
datetime
(
2000
,
1
,
1
)
info
=
fm
.
Info
(
time
=
time
,
grid
=
fm
.
UniformGrid
((
2048
,
1024
)),
units
=
"
m
"
)
xdata
=
full
(
0.0
,
"
test
"
,
info
)
_result
=
self
.
benchmark
(
self
.
copy_xarray_to_xarray
,
data
=
xdata
,
info
=
info
)
class
TestFull
(
unittest
.
TestCase
):
@pytest.fixture
(
autouse
=
True
)
...
...
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