Skip to content
Snippets Groups Projects
Commit 7103c7ae authored by Martin Lange's avatar Martin Lange
Browse files

add benchmarks for push-pull using xarray

parent b8652ff9
No related branches found
No related tags found
1 merge request!213Benchmarks tools and push-pull
Pipeline #132393 passed with stages
in 3 minutes and 35 seconds
......@@ -4,7 +4,8 @@
### Push & pull
Push & pull using numpy arrays
Push & pull using numpy arrays (`np`) and xarray arrays (`xr`).
(xarray benchmarks include a call to `fm.tools.assign_time`)
![tools](https://git.ufz.de/FINAM/finam/-/jobs/artifacts/main/raw/bench/bench-sdk-io.svg?job=benchmark)
......
......@@ -11,16 +11,22 @@ class TestPushPull(unittest.TestCase):
def setupBenchmark(self, benchmark):
self.benchmark = benchmark
def push_pull(self):
def push_pull(self, xr=False):
if xr:
self.data = fm.data.assign_time(self.data, self.time)
self.out.push_data(self.data, self.time)
_ = self.inp.pull_data(self.time)
self.time += dt.timedelta(days=1)
def setup_link(self, grid, target_units):
def setup_link(self, grid, target_units, xr=False):
self.time = dt.datetime(2000, 1, 1)
info1 = fm.Info(time=self.time, grid=grid, units="m")
info2 = fm.Info(time=self.time, grid=grid, units=target_units)
self.data = fm.data.strip_data(fm.data.full(0.0, "test", info1, self.time))
self.data = fm.data.full(0.0, "test", info1, self.time)
if not xr:
self.data = fm.data.strip_data(self.data)
self.out = fm.Output(name="Output")
self.inp = fm.Input(name="Input")
......@@ -43,7 +49,13 @@ class TestPushPull(unittest.TestCase):
self.benchmark(self.push_pull)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_np_03_2048x1024(self):
def test_push_pull_np_03_1024x512(self):
grid = fm.UniformGrid((1024, 512))
self.setup_link(grid, target_units="m")
self.benchmark(self.push_pull)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_np_04_2048x1024(self):
grid = fm.UniformGrid((2048, 1024))
self.setup_link(grid, target_units="m")
self.benchmark(self.push_pull)
......@@ -61,7 +73,61 @@ class TestPushPull(unittest.TestCase):
self.benchmark(self.push_pull)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_np_units_03_2048x1024(self):
def test_push_pull_np_units_03_1024x512(self):
grid = fm.UniformGrid((1024, 512))
self.setup_link(grid, target_units="km")
self.benchmark(self.push_pull)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_np_units_04_2048x1024(self):
grid = fm.UniformGrid((2048, 1024))
self.setup_link(grid, target_units="km")
self.benchmark(self.push_pull)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_01_2x1(self):
grid = fm.UniformGrid((2, 1))
self.setup_link(grid, target_units="m", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_02_512x256(self):
grid = fm.UniformGrid((512, 256))
self.setup_link(grid, target_units="m", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_03_1024x512(self):
grid = fm.UniformGrid((1024, 512))
self.setup_link(grid, target_units="m", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_04_2048x1024(self):
grid = fm.UniformGrid((2048, 1024))
self.setup_link(grid, target_units="m", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_units_01_2x1(self):
grid = fm.UniformGrid((2, 1))
self.setup_link(grid, target_units="km", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_units_02_512x256(self):
grid = fm.UniformGrid((512, 256))
self.setup_link(grid, target_units="km", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_units_03_1024x512(self):
grid = fm.UniformGrid((1024, 512))
self.setup_link(grid, target_units="km", xr=True)
self.benchmark(self.push_pull, xr=True)
@pytest.mark.benchmark(group="sdk-io")
def test_push_pull_xr_units_04_2048x1024(self):
grid = fm.UniformGrid((2048, 1024))
self.setup_link(grid, target_units="km", xr=True)
self.benchmark(self.push_pull, xr=True)
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