Skip to content

Commit c000690

Browse files
hmaarrfkpre-commit-ci[bot]Illviljandcherianmax-sixty
authored
Dataset insertion benchmark (#7223)
* Add a benchmark for dataset element insertion * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update asv_bench/benchmarks/dataset_creation.py * Rework the benchmark * lint before the bot * Update asv_bench/benchmarks/dataset_creation.py Co-authored-by: Deepak Cherian <[email protected]> * Update asv_bench/benchmarks/dataset_creation.py Co-authored-by: Deepak Cherian <[email protected]> * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Lint * Rename the benchmark * Rename benchmark * Update asv_bench/benchmarks/dataset_in_memory_operation.py Co-authored-by: Maximilian Roos <[email protected]> * Update and rename dataset_in_memory_operation.py to merge.py * add back elements * Only add a single variable * Give the parameter a name Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: Illviljan <[email protected]> Co-authored-by: Deepak Cherian <[email protected]> Co-authored-by: Maximilian Roos <[email protected]>
1 parent 076bd8e commit c000690

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

asv_bench/benchmarks/merge.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import xarray as xr
2+
3+
4+
class DatasetAddVariable:
5+
param_names = ["existing_elements"]
6+
params = [[0, 10, 100, 1000]]
7+
8+
def setup(self, existing_elements):
9+
self.datasets = {}
10+
# Dictionary insertion is fast(er) than xarray.Dataset insertion
11+
d = {}
12+
for i in range(existing_elements):
13+
d[f"var{i}"] = i
14+
self.dataset = xr.merge([d])
15+
16+
def time_variable_insertion(self, existin_elements):
17+
dataset = self.dataset
18+
dataset["new_var"] = 0

0 commit comments

Comments
 (0)