Skip to content

Commit 9517b60

Browse files
authored
[skip-ci] Add benchmarks for Dataset binary ops, chunk (#8351)
xref #8339 xref #8350
1 parent b55be51 commit 9517b60

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

asv_bench/benchmarks/dataset.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import numpy as np
2+
3+
from xarray import Dataset
4+
5+
from . import requires_dask
6+
7+
8+
class DatasetBinaryOp:
9+
def setup(self):
10+
self.ds = Dataset(
11+
{
12+
"a": (("x", "y"), np.ones((300, 400))),
13+
"b": (("x", "y"), np.ones((300, 400))),
14+
}
15+
)
16+
self.mean = self.ds.mean()
17+
self.std = self.ds.std()
18+
19+
def time_normalize(self):
20+
(self.ds - self.mean) / self.std
21+
22+
23+
class DatasetChunk:
24+
def setup(self):
25+
requires_dask()
26+
self.ds = Dataset()
27+
array = np.ones(1000)
28+
for i in range(250):
29+
self.ds[f"var{i}"] = ("x", array)
30+
31+
def time_chunk(self):
32+
self.ds.chunk(x=(1,) * 1000)

0 commit comments

Comments
 (0)