from __future__ import annotations
import pytest
from common import CpuBoundDs, cat_collate
from dataloader_rs import PyDataloader
pytestmark = pytest.mark.bench
BATCH_SIZE = 32
@pytest.mark.parametrize(
("num_workers", "item_concurrency"), [(0, 1), (1, 1), (0, 4), (1, 4)], ids=str
)
def test_first_batch(benchmark, num_workers, item_concurrency):
loader = PyDataloader(
CpuBoundDs(BATCH_SIZE),
batch_size=BATCH_SIZE,
collate_fn=cat_collate,
num_workers=num_workers,
item_concurrency=item_concurrency,
)
benchmark.pedantic(lambda: next(iter(loader)), warmup_rounds=1, rounds=10)