File size: 1,229 Bytes
2c3c408 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | import tempfile
import numpy as np
import tiledb
class MultiIndex:
params = [10, 100, 1000, 10_000, 100_000]
def setup(self, _):
self.uri = tempfile.mkdtemp()
self.dmin = -10_000_000
self.dmax = 10_000_000
self.ncoords = 3_000_000
schema = tiledb.ArraySchema(
tiledb.Domain([tiledb.Dim(dtype=np.int64, domain=(self.dmin, self.dmax))]),
attrs=[
tiledb.Attr(name="", dtype="float64", var=False, nullable=False),
],
cell_order="row-major",
tile_order="row-major",
capacity=1000,
sparse=True,
)
tiledb.Array.create(self.uri, schema)
# use `choice` here because randint doesn't support non-replacement
self.coords = np.random.choice(
np.arange(self.dmin, self.dmax + 1), size=self.ncoords, replace=False
)
with tiledb.open(self.uri, "w") as A:
A[self.coords] = np.random.rand(self.ncoords)
def time_multiindex_read(self, coords_count):
coords = np.random.choice(self.coords, size=coords_count, replace=False)
with tiledb.open(self.uri) as A:
A.multi_index[list(coords)]
|