Skip to content

Commit

Permalink
add latency-based test
Browse files Browse the repository at this point in the history
  • Loading branch information
d-v-b committed Nov 26, 2024
1 parent d10d805 commit 4c624e1
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import contextlib
import operator
import pickle
import time
import warnings
from typing import TYPE_CHECKING, Any, Literal

Expand All @@ -22,6 +23,7 @@
from zarr.errors import ContainsArrayError, ContainsGroupError
from zarr.storage import LocalStore, MemoryStore, StorePath, ZipStore
from zarr.storage.common import make_store_path
from zarr.testing.store import LatencyStore

from .conftest import parse_store

Expand Down Expand Up @@ -1484,3 +1486,23 @@ def test_delitem_removes_children(store: Store, zarr_format: ZarrFormat) -> None
del g1["0"]
with pytest.raises(KeyError):
g1["0/0"]


@pytest.mark.parametrize('store', ['memory'], indirect=True)
def test_group_members_performance(store: MemoryStore) -> None:
"""
Test that the performance of Group.members is robust to asynchronous latency
"""
get_latency = 0.1
latency_store = LatencyStore(store, get_latency=get_latency)

group = zarr.group(store=latency_store)
num_groups = 100
# Create some groups
for i in range(num_groups):
group.create_group(f"group{i}")

start= time.time()
members = group.members()
elapsed = start = time.time()
assert elapsed < 2 * get_latency

0 comments on commit 4c624e1

Please sign in to comment.