Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 26 additions & 1 deletion tests/benchmark/test_analog_stream_readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from pytest_benchmark.fixture import BenchmarkFixture

from nidaqmx import Task
from nidaqmx.constants import WaveformAttributeMode
from nidaqmx.constants import READ_ALL_AVAILABLE, WaveformAttributeMode
from nidaqmx.stream_readers._analog_multi_channel_reader import AnalogMultiChannelReader
from nidaqmx.stream_readers._analog_single_channel_reader import (
AnalogSingleChannelReader,
Expand Down Expand Up @@ -39,6 +39,18 @@ def test___analog_single_channel_reader___read_many_sample(
benchmark(reader.read_many_sample, data, num_samples)


@pytest.mark.benchmark(group="analog_readers")
@pytest.mark.parametrize("num_samples", [1, 1000])
def test___analog_single_channel_reader___read_all_available(
benchmark: BenchmarkFixture, ai_benchmark_task: Task, num_samples: int
) -> None:
reader = AnalogSingleChannelReader(ai_benchmark_task.in_stream)
# This test reads the whole buffer, which is 2x num_samples.
data = numpy.full(num_samples * 2, math.inf, dtype=numpy.float64)

benchmark(reader.read_many_sample, data, READ_ALL_AVAILABLE)


@pytest.mark.benchmark(group="analog_readers")
@pytest.mark.parametrize("num_samples", [1, 1000])
@pytest.mark.parametrize(
Expand Down Expand Up @@ -81,6 +93,19 @@ def test___analog_multi_channel_reader___read_many_sample(
benchmark(reader.read_many_sample, data, num_samples)


@pytest.mark.benchmark(group="analog_readers")
@pytest.mark.parametrize("num_channels", [1, 2, 8])
@pytest.mark.parametrize("num_samples", [1, 1000])
def test___analog_multi_channel_reader___read_all_available(
benchmark: BenchmarkFixture, ai_benchmark_task: Task, num_channels: int, num_samples: int
) -> None:
reader = AnalogMultiChannelReader(ai_benchmark_task.in_stream)
# This test reads the whole buffer, which is 2x num_samples.
data = numpy.full((num_channels, num_samples * 2), math.inf, dtype=numpy.float64)

benchmark(reader.read_many_sample, data, READ_ALL_AVAILABLE)


@pytest.mark.benchmark(group="analog_readers")
@pytest.mark.parametrize("num_channels", [1, 2, 8])
@pytest.mark.parametrize("num_samples", [1, 1000])
Expand Down