Skip to content

Commit

Permalink
[skip-ci] Add benchmarks for Dataset binary ops, chunk (#8351)
Browse files Browse the repository at this point in the history
xref #8339
xref #8350
  • Loading branch information
dcherian authored Oct 20, 2023
1 parent b55be51 commit 9517b60
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions asv_bench/benchmarks/dataset.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import numpy as np

from xarray import Dataset

from . import requires_dask


class DatasetBinaryOp:
def setup(self):
self.ds = Dataset(
{
"a": (("x", "y"), np.ones((300, 400))),
"b": (("x", "y"), np.ones((300, 400))),
}
)
self.mean = self.ds.mean()
self.std = self.ds.std()

def time_normalize(self):
(self.ds - self.mean) / self.std


class DatasetChunk:
def setup(self):
requires_dask()
self.ds = Dataset()
array = np.ones(1000)
for i in range(250):
self.ds[f"var{i}"] = ("x", array)

def time_chunk(self):
self.ds.chunk(x=(1,) * 1000)

0 comments on commit 9517b60

Please sign in to comment.