Skip to content

Commit 59041d4

Browse files
committed
feat: add concat sparse benchmarks
1 parent 0f94a19 commit 59041d4

File tree

1 file changed

+25
-1
lines changed

1 file changed

+25
-1
lines changed

benchmarks/benchmarks/sparse_dataset.py

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
from __future__ import annotations
22

3+
import tempfile
34
from types import MappingProxyType
45

56
import numpy as np
67
import zarr
78
from dask.array.core import Array as DaskArray
89
from scipy import sparse
910

10-
from anndata import AnnData
11+
from anndata import AnnData, concat
1112
from anndata._core.sparse_dataset import sparse_dataset
1213
from anndata._io.specs import write_elem
1314
from anndata.experimental import read_elem_lazy
@@ -70,3 +71,26 @@ def peakmem_getitem_adata(self, *_):
7071
res = self.adata[self.slice]
7172
if isinstance(res, DaskArray):
7273
res.compute()
74+
75+
76+
class SparseCSRDask:
77+
def setup(self):
78+
X = sparse.random(
79+
10_000,
80+
10_000,
81+
density=0.01,
82+
format="csr",
83+
random_state=np.random.default_rng(42),
84+
)
85+
self.tmpdir = tempfile.TemporaryDirectory("tmp.zarr")
86+
self.group = zarr.group(self.tmpdir.name)
87+
write_elem(self.group, "X", X)
88+
89+
def time_concat_many(self):
90+
concat([AnnData(X=read_elem_lazy(self.group["X"])) for i in range(100)])
91+
92+
def peakmem_concat_many(self):
93+
concat([AnnData(X=read_elem_lazy(self.group["X"])) for i in range(100)])
94+
95+
def teardown(self):
96+
self.tmpdir.cleanup()

0 commit comments

Comments
 (0)