|
8 | 8 | from pytest_benchmark.fixture import BenchmarkFixture |
9 | 9 |
|
10 | 10 | from nidaqmx import Task |
11 | | -from nidaqmx.constants import WaveformAttributeMode |
| 11 | +from nidaqmx.constants import READ_ALL_AVAILABLE, WaveformAttributeMode |
12 | 12 | from nidaqmx.stream_readers._analog_multi_channel_reader import AnalogMultiChannelReader |
13 | 13 | from nidaqmx.stream_readers._analog_single_channel_reader import ( |
14 | 14 | AnalogSingleChannelReader, |
@@ -39,6 +39,18 @@ def test___analog_single_channel_reader___read_many_sample( |
39 | 39 | benchmark(reader.read_many_sample, data, num_samples) |
40 | 40 |
|
41 | 41 |
|
| 42 | +@pytest.mark.benchmark(group="analog_readers") |
| 43 | +@pytest.mark.parametrize("num_samples", [1, 1000]) |
| 44 | +def test___analog_single_channel_reader___read_all_available( |
| 45 | + benchmark: BenchmarkFixture, ai_benchmark_task: Task, num_samples: int |
| 46 | +) -> None: |
| 47 | + reader = AnalogSingleChannelReader(ai_benchmark_task.in_stream) |
| 48 | + # This test reads the whole buffer, which is 2x num_samples. |
| 49 | + data = numpy.full(num_samples * 2, math.inf, dtype=numpy.float64) |
| 50 | + |
| 51 | + benchmark(reader.read_many_sample, data, READ_ALL_AVAILABLE) |
| 52 | + |
| 53 | + |
42 | 54 | @pytest.mark.benchmark(group="analog_readers") |
43 | 55 | @pytest.mark.parametrize("num_samples", [1, 1000]) |
44 | 56 | @pytest.mark.parametrize( |
@@ -81,6 +93,19 @@ def test___analog_multi_channel_reader___read_many_sample( |
81 | 93 | benchmark(reader.read_many_sample, data, num_samples) |
82 | 94 |
|
83 | 95 |
|
| 96 | +@pytest.mark.benchmark(group="analog_readers") |
| 97 | +@pytest.mark.parametrize("num_channels", [1, 2, 8]) |
| 98 | +@pytest.mark.parametrize("num_samples", [1, 1000]) |
| 99 | +def test___analog_multi_channel_reader___read_all_available( |
| 100 | + benchmark: BenchmarkFixture, ai_benchmark_task: Task, num_channels: int, num_samples: int |
| 101 | +) -> None: |
| 102 | + reader = AnalogMultiChannelReader(ai_benchmark_task.in_stream) |
| 103 | + # This test reads the whole buffer, which is 2x num_samples. |
| 104 | + data = numpy.full((num_channels, num_samples * 2), math.inf, dtype=numpy.float64) |
| 105 | + |
| 106 | + benchmark(reader.read_many_sample, data, READ_ALL_AVAILABLE) |
| 107 | + |
| 108 | + |
84 | 109 | @pytest.mark.benchmark(group="analog_readers") |
85 | 110 | @pytest.mark.parametrize("num_channels", [1, 2, 8]) |
86 | 111 | @pytest.mark.parametrize("num_samples", [1, 1000]) |
|
0 commit comments